<!DOCTYPE html><html class=split lang=en-US-x-hixie><script src=../link-fixup.js defer=""></script>
<!-- Mirrored from html.spec.whatwg.org/multipage/document-sequences.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 10 Sep 2025 08:35:53 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
<meta charset=utf-8><meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name=viewport><title>HTML Standard</title><meta content=#3c790a name=theme-color><meta content="light dark" name=color-scheme><link rel=stylesheet href=../../resources.whatwg.org/standard-shared-with-dev.css crossorigin=""><link rel=stylesheet href=../../resources.whatwg.org/standard.css crossorigin=""><link rel=stylesheet href=../../resources.whatwg.org/spec.css crossorigin=""><link rel=icon href=https://resources.whatwg.org/logo.svg crossorigin=""><link rel=stylesheet href=../styles.css crossorigin=""><script>
   function toggleStatus(div) {
     div.parentNode.classList.toggle('wrapped');
   }
   function setLinkFragment(link) {
     link.hash = location.hash;
   }
  </script><body>
  
  <script defer="" crossorigin="" src=../html-dfn.js></script>
  
  <header id=head class="head with-buttons">
   <a href=https://whatwg.org/ class=logo><img width=100 alt=WHATWG crossorigin="" class=darkmode-aware src=https://resources.whatwg.org/logo.svg height=100></a>
   <hgroup><h1 class=allcaps>HTML</h1><p id=living-standard>Living Standard — Last Updated <span class=pubdate>10 September 2025</span></hgroup>
   
   

   
  </header>

  

  

  

  
  

  
  

  

  <nav><a href=nav-history-apis.html>← 7.2 APIs related to navigation and
  session history</a> — <a href=index.html>Table of Contents</a> — <a href=browsing-the-web.html>7.4 Navigation and session
  history →</a></nav><ol class=toc><li id=toc-browsers><ol><li><a href=document-sequences.html#infrastructure-for-sequences-of-documents><span class=secno>7.3</span> Infrastructure for sequences of documents</a><ol><li><a href=document-sequences.html#navigables><span class=secno>7.3.1</span> Navigables</a><ol><li><a href=document-sequences.html#traversable-navigables><span class=secno>7.3.1.1</span> Traversable navigables</a><li><a href=document-sequences.html#top-level-traversables><span class=secno>7.3.1.2</span> Top-level traversables</a><li><a href=document-sequences.html#child-navigables><span class=secno>7.3.1.3</span> Child navigables</a><li><a href=document-sequences.html#jake-diagrams><span class=secno>7.3.1.4</span> Jake diagrams</a><li><a href=document-sequences.html#related-navigable-collections><span class=secno>7.3.1.5</span> Related navigable collections</a><li><a href=document-sequences.html#garbage-collection-and-browsing-contexts><span class=secno>7.3.1.6</span> Navigable destruction</a><li><a href=document-sequences.html#navigable-target-names><span class=secno>7.3.1.7</span> Navigable target names</a></ol><li><a href=document-sequences.html#windows><span class=secno>7.3.2</span> Browsing contexts</a><ol><li><a href=document-sequences.html#creating-browsing-contexts><span class=secno>7.3.2.1</span> Creating browsing contexts</a><li><a href=document-sequences.html#nested-browsing-contexts><span class=secno>7.3.2.2</span> Related browsing contexts</a><li><a href=document-sequences.html#groupings-of-browsing-contexts><span class=secno>7.3.2.3</span> Groupings of browsing contexts</a></ol><li><a href=document-sequences.html#fully-active-documents><span class=secno>7.3.3</span> Fully active documents</a></ol></ol></ol><h3 id=infrastructure-for-sequences-of-documents><span class=secno>7.3</span> Infrastructure for sequences of documents<a href=#infrastructure-for-sequences-of-documents class=self-link></a></h3>

  <p>This standard contains several related concepts for grouping sequences of documents. As a
  brief, non-normative summary:</p>

  <ul><li><p><a href=#navigable id=infrastructure-for-sequences-of-documents:navigable>Navigables</a> are a user-facing representation of a sequence
   of documents, i.e., they represent something that can be navigated between documents. Typical
   examples are tabs or windows in a web browser, or <code id=infrastructure-for-sequences-of-documents:the-iframe-element><a href=iframe-embed-object.html#the-iframe-element>iframe</a></code>s, or
   <code id=infrastructure-for-sequences-of-documents:frame><a href=obsolete.html#frame>frame</a></code>s in a <code id=infrastructure-for-sequences-of-documents:frameset><a href=obsolete.html#frameset>frameset</a></code>.<li><p><a href=#traversable-navigable id=infrastructure-for-sequences-of-documents:traversable-navigable>Traversable navigables</a> are a special type of
   navigable which control the session history of themselves and of their descendant navigables.
   That is, in addition to their own series of documents, they represent a tree of further series
   of documents, plus the ability to linearly traverse back and forward through a flattened view of
   this tree.<li><p><a href=#browsing-context id=infrastructure-for-sequences-of-documents:browsing-context>Browsing contexts</a> are a developer-facing
   representation of a series of documents. They correspond 1:1 with <code id=infrastructure-for-sequences-of-documents:windowproxy><a href=nav-history-apis.html#windowproxy>WindowProxy</a></code>
   objects. Each navigable can present a series of browsing contexts, with <a href=browsers.html#browsing-context-group-switches-due-to-cross-origin-opener-policy>switches</a> between
   those browsing contexts occuring under certain well-defined circumstances.</ul>

  <p>Most of this standard works in the language of navigables, but certain APIs expose the
  existence of browsing context switches, and so some parts of the standard need to work in terms
  of browsing contexts.</p>

  <h4 id=navigables><span class=secno>7.3.1</span> Navigables<a href=#navigables class=self-link></a></h4>

  <p>A <dfn id=navigable data-export="">navigable</dfn> presents a <code id=navigables:document><a href=dom.html#document>Document</a></code> to the user via its <a href=#nav-active-history-entry id=navigables:nav-active-history-entry>active session history entry</a>. Each navigable has:</p>

  <ul><li><p>An <dfn id=nav-id>id</dfn>, a <a id=navigables:new-unique-internal-value href=common-microsyntaxes.html#new-unique-internal-value>new unique internal value</a>.<li><p id=parent-browsing-context>A <dfn data-dfn-for=navigable id=nav-parent data-export="">parent</dfn>,
   a <a href=#navigable id=navigables:navigable>navigable</a> or null.<li>
    <p id=current-entry>A <dfn id=nav-current-history-entry>current session history
    entry</dfn>, a <a id=navigables:session-history-entry href=browsing-the-web.html#session-history-entry>session history entry</a>.</p>

    <p>This can only be modified within the <a href=#tn-session-history-traversal-queue id=navigables:tn-session-history-traversal-queue>session history traversal queue</a> of the
    parent <a href=#traversable-navigable id=navigables:traversable-navigable>traversable navigable</a>.</p>
   <li>
    <p>An <dfn id=nav-active-history-entry>active session history entry</dfn>, a
    <a id=navigables:session-history-entry-2 href=browsing-the-web.html#session-history-entry>session history entry</a>.</p>

    <p>This can only be modified from the event loop of the <a href=#nav-active-history-entry id=navigables:nav-active-history-entry-2>active session history entry</a>'s <a href=browsing-the-web.html#she-document id=navigables:she-document>document</a>.</p>
   <li>
    <p>An <dfn id=is-closing>is closing</dfn> boolean, initially false.</p>

    <p class=note>This is only ever set to true for <a href=#top-level-traversable id=navigables:top-level-traversable>top-level traversable navigables</a>.</p>
   <li>
    <p>An <dfn id=delaying-load-events-mode>is delaying <code>load</code>
    events</dfn> boolean, initially false.</p>

    <p class=note>This is only ever set to true in cases where the navigable's <a href=#nav-parent id=navigables:nav-parent>parent</a> is non-null.</p>
  </ul>

  <p>The <a href=#nav-current-history-entry id=navigables:nav-current-history-entry>current session history entry</a> and the
  <a href=#nav-active-history-entry id=navigables:nav-active-history-entry-3>active session history entry</a> are usually the same,
  but they get out of sync when:</p>

  <ul><li><p>Synchronous navigations are performed. This causes the <a href=#nav-active-history-entry id=navigables:nav-active-history-entry-4>active session history entry</a> to temporarily step ahead
   of the <a href=#nav-current-history-entry id=navigables:nav-current-history-entry-2>current session history entry</a>.<li><p>A non-displayable, non-error response is received when <a href=browsing-the-web.html#apply-the-history-step id=navigables:apply-the-history-step>applying the history step</a>. This updates the <a href=#nav-current-history-entry id=navigables:nav-current-history-entry-3>current session history entry</a> but leaves the <a href=#nav-active-history-entry id=navigables:nav-active-history-entry-5>active session history entry</a> as-is.</ul>

  <hr>

  <p>A <a href=#navigable id=navigables:navigable-2>navigable</a>'s <dfn data-dfn-for=navigable id=nav-document data-export="">active
  document</dfn> is its <a href=#nav-active-history-entry id=navigables:nav-active-history-entry-6>active session history
  entry</a>'s <a href=browsing-the-web.html#she-document id=navigables:she-document-2>document</a>.</p>

  <p class=note>This can be safely read from within the <a href=#tn-session-history-traversal-queue id=navigables:tn-session-history-traversal-queue-2>session history traversal queue</a> of the
  navigable's <a href=#nav-top id=navigables:nav-top>top-level traversable</a>. Although a
  <a href=#navigable id=navigables:navigable-3>navigable</a>'s <a href=#nav-active-history-entry id=navigables:nav-active-history-entry-7>active history entry</a> can
  change synchronously, the new entry will always have the same <code id=navigables:document-2><a href=dom.html#document>Document</a></code>.</p>

  <p>A <a href=#navigable id=navigables:navigable-4>navigable</a>'s <dfn data-dfn-for=navigable id=nav-bc data-export="">active browsing
  context</dfn> is its <a href=#nav-document id=navigables:nav-document>active document</a>'s <a href=#concept-document-bc id=navigables:concept-document-bc>browsing context</a>. If this <a href=#navigable id=navigables:navigable-5>navigable</a> is a
  <a href=#traversable-navigable id=navigables:traversable-navigable-2>traversable navigable</a>, then its <a href=#nav-bc id=navigables:nav-bc>active browsing context</a>
  will be a <a href=#top-level-browsing-context id=navigables:top-level-browsing-context>top-level browsing context</a>.</p>

  <p>A <a href=#navigable id=navigables:navigable-6>navigable</a>'s <dfn id=nav-wp>active <code>WindowProxy</code></dfn> is its
  <a href=#nav-bc id=navigables:nav-bc-2>active browsing context</a>'s associated <code id=navigables:windowproxy><a href=nav-history-apis.html#windowproxy>WindowProxy</a></code>.</p>

  <p>A <a href=#navigable id=navigables:navigable-7>navigable</a>'s <dfn data-dfn-for=navigable id=nav-window data-export="">active window</dfn>
  is its <a href=#nav-wp id=navigables:nav-wp>active <code>WindowProxy</code></a>'s <a href=nav-history-apis.html#concept-windowproxy-window id=navigables:concept-windowproxy-window>[[Window]]</a>.</p>

  <p class=note>This will always equal the navigable's <a href=#nav-document id=navigables:nav-document-2>active
  document</a>'s <a id=navigables:concept-relevant-global href=webappapis.html#concept-relevant-global>relevant global object</a>; this is kept in sync by the <a id=navigables:make-active href=browsing-the-web.html#make-active>make
  active</a> algorithm.</p>

  <p id=browsing-context-name>A <a href=#navigable id=navigables:navigable-8>navigable</a>'s <dfn id=nav-target>target
  name</dfn> is its <a href=#nav-active-history-entry id=navigables:nav-active-history-entry-8>active session history entry</a>'s
  <a href=browsing-the-web.html#she-document-state id=navigables:she-document-state>document state</a>'s <a href=browsing-the-web.html#document-state-nav-target-name id=navigables:document-state-nav-target-name>navigable target name</a>.</p>

  <hr>

  <p>To get the <dfn id=node-navigable data-export="">node navigable</dfn> of a <a id=navigables:node href=https://dom.spec.whatwg.org/#interface-node data-x-internal=node>node</a> <var>node</var>, return the
  <a href=#navigable id=navigables:navigable-9>navigable</a> whose <a href=#nav-document id=navigables:nav-document-3>active document</a> is
  <var>node</var>'s <a id=navigables:node-document href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a>, or null if there is no such
  <a href=#navigable id=navigables:navigable-10>navigable</a>.</p>

  <hr>

  <p>To <dfn id=initialize-the-navigable>initialize the navigable</dfn> <a href=#navigable id=navigables:navigable-11>navigable</a> <var>navigable</var>, given a
  <a id=navigables:document-state-2 href=browsing-the-web.html#document-state-2>document state</a> <var>documentState</var> and an optional
  <a href=#navigable id=navigables:navigable-12>navigable</a>-or-null <var>parent</var> (default null):</p>

  <ol><li><p><a id=navigables:assert href=https://infra.spec.whatwg.org/#assert data-x-internal=assert>Assert</a>: <var>documentState</var>'s <a href=browsing-the-web.html#document-state-document id=navigables:document-state-document>document</a> is non-null.<li>
    <p>Let <var>entry</var> be a new <a id=navigables:session-history-entry-3 href=browsing-the-web.html#session-history-entry>session history entry</a>, with</p>

    <dl class=props><dt><a href=browsing-the-web.html#she-url id=navigables:she-url>URL</a><dd><var>documentState</var>'s <a href=browsing-the-web.html#document-state-document id=navigables:document-state-document-2>document</a>'s <a href=https://dom.spec.whatwg.org/#concept-document-url id="navigables:the-document's-address" data-x-internal="the-document's-address">URL</a><dt><a href=browsing-the-web.html#she-document-state id=navigables:she-document-state-2>document state</a><dd><var>documentState</var></dl>

    <p class=note>The caller of this algorithm is responsible for initializing <var>entry</var>'s
    <a href=browsing-the-web.html#she-step id=navigables:she-step>step</a>; it will be left as "<code>pending</code>" until
    that is complete.</p>
   <li><p>Set <var>navigable</var>'s <a href=#nav-current-history-entry id=navigables:nav-current-history-entry-4>current session
   history entry</a> to <var>entry</var>.<li><p>Set <var>navigable</var>'s <a href=#nav-active-history-entry id=navigables:nav-active-history-entry-9>active session history
   entry</a> to <var>entry</var>.<li><p>Set <var>navigable</var>'s <a href=#nav-parent id=navigables:nav-parent-2>parent</a> to
   <var>parent</var>.</ol>


  <h5 id=traversable-navigables><span class=secno>7.3.1.1</span> Traversable navigables<a href=#traversable-navigables class=self-link></a></h5>

  <p>A <dfn id=traversable-navigable data-export="">traversable navigable</dfn> is a <a href=#navigable id=traversable-navigables:navigable>navigable</a> that also controls which
  <a id=traversable-navigables:session-history-entry href=browsing-the-web.html#session-history-entry>session history entry</a> should be the <a href=#nav-current-history-entry id=traversable-navigables:nav-current-history-entry>current
  session history entry</a> and <a href=#nav-active-history-entry id=traversable-navigables:nav-active-history-entry>active session history
  entry</a> for itself and its descendant <a href=#navigable id=traversable-navigables:navigable-2>navigables</a>.</p>

  <p>In addition to the properties of a <a href=#navigable id=traversable-navigables:navigable-3>navigable</a>, a <a href=#traversable-navigable id=traversable-navigables:traversable-navigable>traversable
  navigable</a> has:</p>

  <ul><li><p>A <dfn id=tn-current-session-history-step data-export="">current session history
   step</dfn>, a number, initially 0.<li><p id=session-history><dfn id=tn-session-history-entries>Session history
   entries</dfn>, a <a id=traversable-navigables:list href=https://infra.spec.whatwg.org/#list data-x-internal=list>list</a> of <a href=browsing-the-web.html#session-history-entry id=traversable-navigables:session-history-entry-2>session history
   entries</a>, initially a new <a id=traversable-navigables:list-2 href=https://infra.spec.whatwg.org/#list data-x-internal=list>list</a>.<li><p>A <dfn id=tn-session-history-traversal-queue>session history traversal queue</dfn>,
   a <a id=traversable-navigables:session-history-traversal-parallel-queue href=browsing-the-web.html#session-history-traversal-parallel-queue>session history traversal parallel queue</a>, the result of <a id=traversable-navigables:starting-a-new-session-history-traversal-parallel-queue href=browsing-the-web.html#starting-a-new-session-history-traversal-parallel-queue>starting a new
   session history traversal parallel queue</a>.<li><p>A <dfn id=tn-running-nested-apply-history-step>running nested apply history
   step</dfn> boolean, initially false.<li>
    <p>A <dfn id=system-visibility-state>system visibility state</dfn>, which is either "<code>hidden</code>" or
    "<code>visible</code>".</p>

    <p>See the <a href=interaction.html#page-visibility>page visibility</a> section for the requirements on this
    item.</p>
   <li><p>An <dfn id=is-created-by-web-content>is created by web content</dfn> boolean, initially false.</ul>

  <p>To get the <dfn data-dfn-for=navigable id=nav-traversable data-export="">traversable navigable</dfn> of
  a <a href=#navigable id=traversable-navigables:navigable-4>navigable</a> <var>inputNavigable</var>:</p>

  <ol><li><p>Let <var>navigable</var> be <var>inputNavigable</var>.<li><p>While <var>navigable</var> is not a <a href=#traversable-navigable id=traversable-navigables:traversable-navigable-2>traversable navigable</a>, set
   <var>navigable</var> to <var>navigable</var>'s <a href=#nav-parent id=traversable-navigables:nav-parent>parent</a>.<li><p>Return <var>navigable</var>.</ol>

  <h5 id=top-level-traversables><span class=secno>7.3.1.2</span> Top-level traversables<a href=#top-level-traversables class=self-link></a></h5>

  <p>A <dfn id=top-level-traversable data-export="">top-level traversable</dfn> is a <a href=#traversable-navigable id=top-level-traversables:traversable-navigable>traversable navigable</a> with a null
  <a href=#nav-parent id=top-level-traversables:nav-parent>parent</a>.</p>

  <p class=note>Currently, all <a href=#traversable-navigable id=top-level-traversables:traversable-navigable-2>traversable navigables</a>
  are <a href=#top-level-traversable id=top-level-traversables:top-level-traversable>top-level traversables</a>. Future proposals envision
  introducing non-top-level traversables.</p>

  <p>A user agent holds a <dfn data-dfn-for="user agent" id=top-level-traversable-set data-export="">top-level traversable set</dfn> (a
  <a id=top-level-traversables:set href=https://infra.spec.whatwg.org/#ordered-set data-x-internal=set>set</a> of <a href=#top-level-traversable id=top-level-traversables:top-level-traversable-2>top-level traversables</a>). These are
  typically presented to the user in the form of browser windows or browser tabs.</p>

  <p>To get the <dfn data-dfn-for=navigable id=nav-top data-export="">top-level traversable</dfn> of a
  <a href=#navigable id=top-level-traversables:navigable>navigable</a> <var>inputNavigable</var>:</p>

  <ol><li><p>Let <var>navigable</var> be <var>inputNavigable</var>.<li><p>While <var>navigable</var>'s <a href=#nav-parent id=top-level-traversables:nav-parent-2>parent</a> is not null, set
   <var>navigable</var> to <var>navigable</var>'s <a href=#nav-parent id=top-level-traversables:nav-parent-3>parent</a>.<li><p>Return <var>navigable</var>.</ol>

  <p>To <dfn id=creating-a-new-top-level-traversable>create a new top-level traversable</dfn>
  given a <a href=#browsing-context id=top-level-traversables:browsing-context>browsing context</a>-or-null <var>opener</var>, a string
  <var>targetName</var>, and an optional <a href=#navigable id=top-level-traversables:navigable-2>navigable</a>
  <var>openerNavigableForWebDriver</var>:</p>

  <ol><li><p>Let <var>document</var> be null.<li><p>If <var>opener</var> is null, then set <var>document</var> to the second return value of
   <a href=#creating-a-new-top-level-browsing-context id=top-level-traversables:creating-a-new-top-level-browsing-context>creating a new top-level browsing context and document</a>.<li><p>Otherwise, set <var>document</var> to the second return value of <a href=#creating-a-new-auxiliary-browsing-context id=top-level-traversables:creating-a-new-auxiliary-browsing-context>creating a new
   auxiliary browsing context and document</a> given <var>opener</var>.<li>
    <p>Let <var>documentState</var> be a new <a id=top-level-traversables:document-state-2 href=browsing-the-web.html#document-state-2>document state</a>, with</p>

    <dl class=props><dt><a href=browsing-the-web.html#document-state-document id=top-level-traversables:document-state-document>document</a><dd><var>document</var><dt><a href=browsing-the-web.html#document-state-initiator-origin id=top-level-traversables:document-state-initiator-origin>initiator origin</a><dd>null if <var>opener</var> is null; otherwise, <var>document</var>'s <a href=https://dom.spec.whatwg.org/#concept-document-origin id=top-level-traversables:concept-document-origin data-x-internal=concept-document-origin>origin</a><dt><a href=browsing-the-web.html#document-state-origin id=top-level-traversables:document-state-origin>origin</a><dd><var>document</var>'s <a href=https://dom.spec.whatwg.org/#concept-document-origin id=top-level-traversables:concept-document-origin-2 data-x-internal=concept-document-origin>origin</a><dt><a href=browsing-the-web.html#document-state-nav-target-name id=top-level-traversables:document-state-nav-target-name>navigable target name</a><dd><var>targetName</var><dt><a href=browsing-the-web.html#document-state-about-base-url id=top-level-traversables:document-state-about-base-url>about base URL</a><dd><var>document</var>'s <a href=dom.html#concept-document-about-base-url id=top-level-traversables:concept-document-about-base-url>about base
     URL</a></dl>
   <li><p>Let <var>traversable</var> be a new <a href=#traversable-navigable id=top-level-traversables:traversable-navigable-3>traversable navigable</a>.<li><p><a href=#initialize-the-navigable id=top-level-traversables:initialize-the-navigable>Initialize the navigable</a> <var>traversable</var> given
   <var>documentState</var>.<li><p>Let <var>initialHistoryEntry</var> be <var>traversable</var>'s <a href=#nav-active-history-entry id=top-level-traversables:nav-active-history-entry>active session history entry</a>.<li><p>Set <var>initialHistoryEntry</var>'s <a href=browsing-the-web.html#she-step id=top-level-traversables:she-step>step</a> to 0.<li><p><a href=https://infra.spec.whatwg.org/#list-append id=top-level-traversables:list-append data-x-internal=list-append>Append</a> <var>initialHistoryEntry</var> to
   <var>traversable</var>'s <a href=#tn-session-history-entries id=top-level-traversables:tn-session-history-entries>session history
   entries</a>.<li id=copy-session-storage><p>If <var>opener</var> is non-null, then <a id=top-level-traversables:legacy-clone-a-traversable-storage-shed href=https://storage.spec.whatwg.org/#legacy-clone-a-traversable-storage-shed data-x-internal=legacy-clone-a-traversable-storage-shed>legacy-clone a
   traversable storage shed</a> given <var>opener</var>'s <a href=#bc-traversable id=top-level-traversables:bc-traversable>top-level
   traversable</a> and <var>traversable</var>. <a href=references.html#refsSTORAGE>[STORAGE]</a><li><p><a href=https://infra.spec.whatwg.org/#list-append id=top-level-traversables:list-append-2 data-x-internal=list-append>Append</a> <var>traversable</var> to the user agent's
   <a href=#top-level-traversable-set id=top-level-traversables:top-level-traversable-set>top-level traversable set</a>.<li><p>Invoke <a id=top-level-traversables:webdriver-bidi-navigable-created href=https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigable-created data-x-internal=webdriver-bidi-navigable-created>WebDriver BiDi navigable created</a> with <var>traversable</var>
   and <var>openerNavigableForWebDriver</var>.<li><p>Return <var>traversable</var>.</ol>

  <p>To <dfn id=create-a-fresh-top-level-traversable data-export="">create a fresh top-level traversable</dfn> given a <a id=top-level-traversables:url href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a>
  <var>initialNavigationURL</var> and an optional <a id=top-level-traversables:post-resource href=browsing-the-web.html#post-resource>POST resource</a>-or-null
  <var>initialNavigationPostResource</var> (default null):</p>

  <ol><li><p>Let <var>traversable</var> be the result of <a href=#creating-a-new-top-level-traversable id=top-level-traversables:creating-a-new-top-level-traversable>creating a new top-level
   traversable</a> given null and the empty string.<li>
    <p><a id=top-level-traversables:navigate href=browsing-the-web.html#navigate>Navigate</a> <var>traversable</var> to <var>initialNavigationURL</var> using
    <var>traversable</var>'s <a href=#nav-document id=top-level-traversables:nav-document>active document</a>, with <i id=top-level-traversables:navigation-resource><a href=browsing-the-web.html#navigation-resource>documentResource</a></i> set to
    <var>initialNavigationPostResource</var>.</p>

    <p class=note>We treat these initial navigations as <var>traversable</var> navigating itself,
    which will ensure all relevant security checks pass.</p>
   <li><p>Return <var>traversable</var>.</ol>


  <h5 id=child-navigables><span class=secno>7.3.1.3</span> Child navigables<a href=#child-navigables class=self-link></a></h5>

  <p id=browsing-context-container>Certain elements (for example, <code id=child-navigables:the-iframe-element><a href=iframe-embed-object.html#the-iframe-element>iframe</a></code> elements)
  can present a <a href=#navigable id=child-navigables:navigable>navigable</a> to the user. These elements are called <dfn id=navigable-container data-lt="navigable container" data-export="">navigable containers</dfn>.</p>

  <p id=nested-browsing-context>Each <a href=#navigable-container id=child-navigables:navigable-container>navigable container</a> has a <dfn data-dfn-for="navigable container" id=content-navigable data-export="">content navigable</dfn>, which is either a <a href=#navigable id=child-navigables:navigable-2>navigable</a> or
  null. It is initially null.</p>

  <p id=bc-container>The <dfn data-dfn-for=navigable id=nav-container data-export="">container</dfn> of a
  <a href=#navigable id=child-navigables:navigable-3>navigable</a> <var>navigable</var> is the <a href=#navigable-container id=child-navigables:navigable-container-2>navigable container</a> whose
  <a href=#content-navigable id=child-navigables:content-navigable>content navigable</a> is <var>navigable</var>, or null if there is no such element.</p>

  <p id=bc-container-document>The <dfn data-dfn-for=navigable id=nav-container-document data-export="">container document</dfn> of a <a href=#navigable id=child-navigables:navigable-4>navigable</a>
  <var>navigable</var> is the result of running these steps:</p>

  <ol><li><p>If <var>navigable</var>'s <a href=#nav-container id=child-navigables:nav-container>container</a> is null, then
   return null.<li>
    <p>Return <var>navigable</var>'s <a href=#nav-container id=child-navigables:nav-container-2>container</a>'s <a id=child-navigables:node-document href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node
    document</a>.</p>

    <p class=note>This is equal to <var>navigable</var>'s <a href=#nav-container id=child-navigables:nav-container-3>container</a>'s <a id=child-navigables:shadow-including-root href=https://dom.spec.whatwg.org/#concept-shadow-including-root data-x-internal=shadow-including-root>shadow-including root</a> as
    <var>navigable</var>'s <a href=#nav-container id=child-navigables:nav-container-4>container</a> has to be
    <a id=child-navigables:connected href=https://dom.spec.whatwg.org/#connected data-x-internal=connected>connected</a>.</p>
   </ol>

  <p>The <dfn id=doc-container-document>container document</dfn> of a <code id=child-navigables:document><a href=dom.html#document>Document</a></code>
  <var>document</var> is the result of running these steps:</p>

  <ol><li><p>If <var>document</var>'s <a href=#node-navigable id=child-navigables:node-navigable>node navigable</a> is null, then return null.<li><p>Return <var>document</var>'s <a href=#node-navigable id=child-navigables:node-navigable-2>node navigable</a>'s <a href=#nav-container-document id=child-navigables:nav-container-document>container document</a>.</ol>

  <p id=child-browsing-context>A <a href=#navigable id=child-navigables:navigable-5>navigable</a> <var>navigable</var> is a <dfn id=child-navigable data-export="">child navigable</dfn> of another navigable <var>potentialParent</var> when
  <var>navigable</var>'s <a href=#nav-parent id=child-navigables:nav-parent>parent</a> is <var>potentialParent</var>. We
  can also just say that a <a href=#navigable id=child-navigables:navigable-6>navigable</a> "is a <a href=#child-navigable id=child-navigables:child-navigable>child navigable</a>", which means
  that its <a href=#nav-parent id=child-navigables:nav-parent-2>parent</a> is non-null.</p>

  <p class=note>All <a href=#child-navigable id=child-navigables:child-navigable-2>child navigables</a> are the <a href=#content-navigable id=child-navigables:content-navigable-2>content
  navigable</a> of their <a href=#nav-container id=child-navigables:nav-container-5>container</a>.</p>

  <p>The <dfn id=concept-bcc-content-document>content document</dfn> of a <a href=#navigable-container id=child-navigables:navigable-container-3>navigable
  container</a> <var>container</var> is the result of running these steps:</p>

  <ol><li><p>If <var>container</var>'s <a href=#content-navigable id=child-navigables:content-navigable-3>content navigable</a> is null, then return
   null.<li><p>Let <var>document</var> be <var>container</var>'s <a href=#content-navigable id=child-navigables:content-navigable-4>content navigable</a>'s <a href=#nav-document id=child-navigables:nav-document>active document</a>.<li><p>If <var>document</var>'s <a href=https://dom.spec.whatwg.org/#concept-document-origin id=child-navigables:concept-document-origin data-x-internal=concept-document-origin>origin</a> and
   <var>container</var>'s <a id=child-navigables:node-document-2 href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a>'s <a href=https://dom.spec.whatwg.org/#concept-document-origin id=child-navigables:concept-document-origin-2 data-x-internal=concept-document-origin>origin</a> are not <a id=child-navigables:same-origin-domain href=browsers.html#same-origin-domain>same origin-domain</a>, then
   return null.<li><p>Return <var>document</var>.</ol>

  <p>The <dfn id=content-window>content window</dfn> of a <a href=#navigable-container id=child-navigables:navigable-container-4>navigable container</a> <var>container</var> is the
  result of running these steps:</p>

  <ol><li><p>If <var>container</var>'s <a href=#content-navigable id=child-navigables:content-navigable-5>content navigable</a> is null, then return
   null.<li><p>Return <var>container</var>'s <a href=#content-navigable id=child-navigables:content-navigable-6>content navigable</a>'s <a href=#nav-wp id=child-navigables:nav-wp>active <code>WindowProxy</code></a>'s object.</ol>

  <hr>

  <p id=creating-a-new-nested-browsing-context>To <dfn id=create-a-new-child-navigable>create a new child navigable</dfn>, given
  an element <var>element</var>:</p>

  <ol><li><p>Let <var>parentNavigable</var> be <var>element</var>'s <a href=#node-navigable id=child-navigables:node-navigable-3>node
   navigable</a>.<li><p>Let <var>group</var> be <var>element</var>'s <a id=child-navigables:node-document-3 href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a>'s <a href=#concept-document-bc id=child-navigables:concept-document-bc>browsing context</a>'s <a href=#bc-tlbc id=child-navigables:bc-tlbc>top-level browsing
   context</a>'s <a href=#tlbc-group id=child-navigables:tlbc-group>group</a>.<li><p>Let <var>browsingContext</var> and <var>document</var> be the result of <a href=#creating-a-new-browsing-context id=child-navigables:creating-a-new-browsing-context>creating a
   new browsing context and document</a> given <var>element</var>'s <a id=child-navigables:node-document-4 href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a>,
   <var>element</var>, and <var>group</var>.<li><p>Let <var>targetName</var> be null.<li><p>If <var>element</var> has a <code>name</code> content attribute, then set
   <var>targetName</var> to the value of that attribute.<li>
    <p>Let <var>documentState</var> be a new <a id=child-navigables:document-state-2 href=browsing-the-web.html#document-state-2>document state</a>, with</p>

    <dl class=props><dt><a href=browsing-the-web.html#document-state-document id=child-navigables:document-state-document>document</a><dd><var>document</var><dt><a href=browsing-the-web.html#document-state-initiator-origin id=child-navigables:document-state-initiator-origin>initiator origin</a><dd><var>document</var>'s <a href=https://dom.spec.whatwg.org/#concept-document-origin id=child-navigables:concept-document-origin-3 data-x-internal=concept-document-origin>origin</a><dt><a href=browsing-the-web.html#document-state-origin id=child-navigables:document-state-origin>origin</a><dd><var>document</var>'s <a href=https://dom.spec.whatwg.org/#concept-document-origin id=child-navigables:concept-document-origin-4 data-x-internal=concept-document-origin>origin</a><dt><a href=browsing-the-web.html#document-state-nav-target-name id=child-navigables:document-state-nav-target-name>navigable target name</a><dd><var>targetName</var><dt><a href=browsing-the-web.html#document-state-about-base-url id=child-navigables:document-state-about-base-url>about base URL</a><dd><var>document</var>'s <a href=dom.html#concept-document-about-base-url id=child-navigables:concept-document-about-base-url>about base
     URL</a></dl>
   <li><p>Let <var>navigable</var> be a new <a href=#navigable id=child-navigables:navigable-7>navigable</a>.<li><p><a href=#initialize-the-navigable id=child-navigables:initialize-the-navigable>Initialize the navigable</a> <var>navigable</var> given <var>documentState</var>
   and <var>parentNavigable</var>.<li><p>Set <var>element</var>'s <a href=#content-navigable id=child-navigables:content-navigable-7>content navigable</a> to <var>navigable</var>.<li><p>Let <var>historyEntry</var> be <var>navigable</var>'s <a href=#nav-active-history-entry id=child-navigables:nav-active-history-entry>active session history entry</a>.<li><p>Let <var>traversable</var> be <var>parentNavigable</var>'s <a href=#nav-traversable id=child-navigables:nav-traversable>traversable navigable</a>.<li>
    <p><a href=browsing-the-web.html#tn-append-session-history-traversal-steps id=child-navigables:tn-append-session-history-traversal-steps>Append the following session
    history traversal steps</a> to <var>traversable</var>:</p>

    <ol><li><p>Let <var>parentDocState</var> be <var>parentNavigable</var>'s <a href=#nav-active-history-entry id=child-navigables:nav-active-history-entry-2>active session history entry</a>'s <a href=browsing-the-web.html#she-document-state id=child-navigables:she-document-state>document state</a>.<li><p>Let <var>parentNavigableEntries</var> be the result of <a id=child-navigables:getting-session-history-entries href=browsing-the-web.html#getting-session-history-entries>getting session history
     entries</a> for <var>parentNavigable</var>.<li><p>Let <var>targetStepSHE</var> be the first <a id=child-navigables:session-history-entry href=browsing-the-web.html#session-history-entry>session history entry</a> in
     <var>parentNavigableEntries</var> whose <a href=browsing-the-web.html#she-document-state id=child-navigables:she-document-state-2>document
     state</a> equals <var>parentDocState</var>.<li><p>Set <var>historyEntry</var>'s <a href=browsing-the-web.html#she-step id=child-navigables:she-step>step</a> to
     <var>targetStepSHE</var>'s <a href=browsing-the-web.html#she-step id=child-navigables:she-step-2>step</a>.<li><p>Let <var>nestedHistory</var> be a new <a id=child-navigables:nested-history href=browsing-the-web.html#nested-history>nested history</a> whose <a href=browsing-the-web.html#nested-history-id id=child-navigables:nested-history-id>id</a> is <var>navigable</var>'s <a href=#nav-id id=child-navigables:nav-id>id</a>
     and <a href=browsing-the-web.html#nested-history-entries id=child-navigables:nested-history-entries>entries list</a> is « <var>historyEntry</var>
     ».<li><p><a href=https://infra.spec.whatwg.org/#list-append id=child-navigables:list-append data-x-internal=list-append>Append</a> <var>nestedHistory</var> to
     <var>parentDocState</var>'s <a href=browsing-the-web.html#document-state-nested-histories id=child-navigables:document-state-nested-histories>nested
     histories</a>.<li><p><a id=child-navigables:update-for-navigable-creation/destruction href=browsing-the-web.html#update-for-navigable-creation/destruction>Update for navigable creation/destruction</a> given
     <var>traversable</var>.</ol>
   <li><p>Invoke <a id=child-navigables:webdriver-bidi-navigable-created href=https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigable-created data-x-internal=webdriver-bidi-navigable-created>WebDriver BiDi navigable created</a> with <var>traversable</var>.</ol>


  <h5 id=jake-diagrams><span class=secno>7.3.1.4</span> Jake diagrams<a href=#jake-diagrams class=self-link></a></h5>

  <p>A useful method for visualizing sequences of documents, and in particular <a href=#navigable id=jake-diagrams:navigable>navigables</a> and their <a href=browsing-the-web.html#session-history-entry id=jake-diagrams:session-history-entry>session
  history entries</a>, is the <dfn id=jake-diagram>Jake diagram</dfn>. A typical Jake diagram is the
  following:</p>

  
  <table class=jake-diagram><thead><tr><td><th class=step>0<th class="step current">1<th class=step>2<th class=step>3<th class=step>4<tbody><tr><th><code>top</code><td colspan=3 class="doc-0 current next-is-same-doc">/t-a<td colspan=1 class="doc-0 prev-is-same-doc">/t-a#foo<td colspan=1 class=doc-1>/t-b<tr><th><code>frames[0]</code><td colspan=1 class=doc-2>/i-0-a<td colspan=3 class="doc-3 current">/i-0-b<tr><th><code>frames[1]</code><td colspan=2 class="doc-4 current">/i-1-a<td colspan=2 class=doc-5>/i-1-b</table>

  <p>Here, each numbered column denotes a possible value for the traversable's <a href=#tn-current-session-history-step id=jake-diagrams:tn-current-session-history-step>session history step</a>. Each labeled row depicts a
  <a href=#navigable id=jake-diagrams:navigable-2>navigable</a>, as it transitions between different URLs and documents. The first,
  labeled <code>top</code>, being the <a href=#top-level-traversable id=jake-diagrams:top-level-traversable>top-level traversable</a>, and the others
  being <a href=#child-navigable id=jake-diagrams:child-navigable>child navigables</a>. The documents are given by the
  background color of each cell, with a new background color indicating a new document in that
  <a href=#navigable id=jake-diagrams:navigable-3>navigable</a>. The URLs are given by the text content of the cells; usually they are
  given as <a href=https://url.spec.whatwg.org/#syntax-url-relative id=jake-diagrams:relative-url data-x-internal=relative-url>relative URLs</a> for brevity, unless a cross-origin case
  is specifically under investigation. A given navigable might not exist at a given step, in which
  case the corresponding cells are empty. The bold-italic step number depicts the <a href=#tn-current-session-history-step id=jake-diagrams:tn-current-session-history-step-2>current session history step</a> of the traversable,
  and all cells with bold-italic URLs represent the <a href=#nav-current-history-entry id=jake-diagrams:nav-current-history-entry>current session history entry</a> for that row's
  navigable.</p>

  <p>Thus, the above Jake diagram depicts the following sequence of events:</p>

  <ol start=0><li><p>A <a href=#top-level-traversable id=jake-diagrams:top-level-traversable-2>top-level traversable</a> is created, starting at the URL <code>/t-a</code>, with two <a href=#child-navigable id=jake-diagrams:child-navigable-2>child navigables</a>
   starting at <code>/i-0-a</code> and <code>/i-1-a</code>
   respectively.<li><p>The first child navigable is <a href=browsing-the-web.html#navigate id=jake-diagrams:navigate>navigated</a> to another
   document, with URL <code>/i-0-b</code>.<li><p>The second child navigable is <a href=browsing-the-web.html#navigate id=jake-diagrams:navigate-2>navigated</a> to another
   document, with URL <code>/i-1-b</code>.<li><p>The top-level traversable is <a href=browsing-the-web.html#navigate id=jake-diagrams:navigate-3>navigated</a> to the
   <em>same</em> document, updating its URL to <code>/t-a#foo</code>.<li><p>The top-level traversable is <a href=browsing-the-web.html#navigate id=jake-diagrams:navigate-4>navigated</a> to another
   document, with URL <code>/t-b</code>. (Notice how this document, of course, does not
   carry over the old document's child navigables.)<li><p>The traversable was <a href=browsing-the-web.html#traverse-the-history-by-a-delta id=jake-diagrams:traverse-the-history-by-a-delta>traversed by a
   delta</a> of −3, back to step 1.</ol>

  <p><a href=#jake-diagram id=jake-diagrams:jake-diagram>Jake diagrams</a> are a powerful tool for visualizing the
  interactions of multiple navigables, navigations, and traversals. They cannot capture every
  possible interaction — for example, they only work with a single level of nesting —
  but we will have ocassion to use them to illustrate several complex situations throughout this
  standard.</p>

  <p class=note><a href=#jake-diagram id=jake-diagrams:jake-diagram-2>Jake diagrams</a> are named after their creator,
  the inimitable Jake Archibald.</p>


  <h5 id=related-navigable-collections><span class=secno>7.3.1.5</span> Related navigable collections<a href=#related-navigable-collections class=self-link></a></h5>

  <p>It is often helpful in this standard's algorithms to look at collections of <a href=#navigable id=related-navigable-collections:navigable>navigables</a> starting at a given <code id=related-navigable-collections:document><a href=dom.html#document>Document</a></code>. This section
  contains a curated set of algorithms for collecting those navigables.</p>

  <p class=note>The return values of these algorithms are ordered so that parents appears before
  their children. Callers rely on this ordering.</p>

  <p class=note>Starting with a <code id=related-navigable-collections:document-2><a href=dom.html#document>Document</a></code>, rather than a <a href=#navigable id=related-navigable-collections:navigable-2>navigable</a>, is
  generally better because it makes the caller cognizant of whether they are starting with a
  <a href=#fully-active id=related-navigable-collections:fully-active>fully active</a> <code id=related-navigable-collections:document-3><a href=dom.html#document>Document</a></code> or not. Although non-<a href=#fully-active id=related-navigable-collections:fully-active-2>fully active</a>
  <code id=related-navigable-collections:document-4><a href=dom.html#document>Document</a></code>s do have ancestor and descendant navigables, they often behave as if they
  don't (e.g., in the <code id=related-navigable-collections:dom-parent><a href=nav-history-apis.html#dom-parent>window.parent</a></code> getter).</p>

  <p>The <dfn data-dfn-for=Document id=ancestor-navigables data-export="">ancestor navigables</dfn> of a <code id=related-navigable-collections:document-5><a href=dom.html#document>Document</a></code>
  <var>document</var> are given by these steps:</p>

  <ol><li><p>Let <var>navigable</var> be <var>document</var>'s <a href=#node-navigable id=related-navigable-collections:node-navigable>node navigable</a>'s <a href=#nav-parent id=related-navigable-collections:nav-parent>parent</a>.<li><p>Let <var>ancestors</var> be an empty list.</p>

   <li>
    <p>While <var>navigable</var> is not null:</p>

    <ol><li><p><a href=https://infra.spec.whatwg.org/#list-prepend id=related-navigable-collections:list-prepend data-x-internal=list-prepend>Prepend</a> <var>navigable</var> to
     <var>ancestors</var>.<li><p>Set <var>navigable</var> to <var>navigable</var>'s <a href=#nav-parent id=related-navigable-collections:nav-parent-2>parent</a>.</ol>
   <li><p>Return <var>ancestors</var>.</ol>

  <p>The <dfn data-dfn-for=Document id=inclusive-ancestor-navigables data-export="">inclusive ancestor navigables</dfn> of a <code id=related-navigable-collections:document-6><a href=dom.html#document>Document</a></code>
  <var>document</var> are given by these steps:</p>

  <ol><li><p>Let <var>navigables</var> be <var>document</var>'s <a href=#ancestor-navigables id=related-navigable-collections:ancestor-navigables>ancestor
   navigables</a>.<li><p><a href=https://infra.spec.whatwg.org/#list-append id=related-navigable-collections:list-append data-x-internal=list-append>Append</a> <var>document</var>'s <a href=#node-navigable id=related-navigable-collections:node-navigable-2>node
   navigable</a> to <var>navigables</var>.<li><p>Return <var>navigables</var>.</ol>

  <p id=list-of-the-descendant-browsing-contexts>The <dfn data-dfn-for=Document id=descendant-navigables data-export="">descendant
  navigables</dfn> of a <code id=related-navigable-collections:document-7><a href=dom.html#document>Document</a></code> <var>document</var> are given by these steps:</p>

  <ol><li><p>Let <var>navigables</var> be new <a id=related-navigable-collections:list href=https://infra.spec.whatwg.org/#list data-x-internal=list>list</a>.<li><p>Let <var>navigableContainers</var> be a <a id=related-navigable-collections:list-2 href=https://infra.spec.whatwg.org/#list data-x-internal=list>list</a> of all <a href=https://dom.spec.whatwg.org/#concept-shadow-including-descendant id=related-navigable-collections:shadow-including-descendant data-x-internal=shadow-including-descendant>shadow-including descendants</a> of <var>document</var>
   that are <a href=#navigable-container id=related-navigable-collections:navigable-container>navigable containers</a>, in
   <a id=related-navigable-collections:shadow-including-tree-order href=https://dom.spec.whatwg.org/#concept-shadow-including-tree-order data-x-internal=shadow-including-tree-order>shadow-including tree order</a>.<li>
    <p><a href=https://infra.spec.whatwg.org/#list-iterate id=related-navigable-collections:list-iterate data-x-internal=list-iterate>For each</a> <var>navigableContainer</var> of
    <var>navigableContainers</var>:</p>

    <ol><li><p>If <var>navigableContainer</var>'s <a href=#content-navigable id=related-navigable-collections:content-navigable>content navigable</a> is null, then
     continue.<li><p><a href=https://infra.spec.whatwg.org/#list-extend id=related-navigable-collections:list-extend data-x-internal=list-extend>Extend</a> <var>navigables</var> with
     <var>navigableContainer</var>'s <a href=#content-navigable id=related-navigable-collections:content-navigable-2>content navigable</a>'s <a href=#nav-document id=related-navigable-collections:nav-document>active document</a>'s <a href=#inclusive-descendant-navigables id=related-navigable-collections:inclusive-descendant-navigables>inclusive descendant
     navigables</a>.</ol>
   <li><p>Return <var>navigables</var>.</ol>

  <p>The <dfn data-dfn-for=Document id=inclusive-descendant-navigables data-export="">inclusive descendant navigables</dfn> of a
  <code id=related-navigable-collections:document-8><a href=dom.html#document>Document</a></code> <var>document</var> are given by these steps:</p>

  <ol><li><p>Let <var>navigables</var> be « <var>document</var>'s <a href=#node-navigable id=related-navigable-collections:node-navigable-3>node navigable</a>
   ».<li><p><a href=https://infra.spec.whatwg.org/#list-extend id=related-navigable-collections:list-extend-2 data-x-internal=list-extend>Extend</a> <var>navigables</var> with <var>document</var>'s
   <a href=#descendant-navigables id=related-navigable-collections:descendant-navigables>descendant navigables</a>.<li><p>Return <var>navigables</var>.</ol>

  <p class=note>These descendant-collecting algorithms are described as looking at the DOM tree
  of descendant <code id=related-navigable-collections:document-9><a href=dom.html#document>Document</a></code> objects. In reality, this is often not feasible since the DOM
  tree can be in another process from the caller of the algorithm. Instead, implementations
  generally replicate the appropriate trees across processes.</p>

  <p id=document-tree-child-browsing-context>The <dfn id=document-tree-child-navigables>document-tree child navigables</dfn> of a
  <code id=related-navigable-collections:document-10><a href=dom.html#document>Document</a></code> <var>document</var> are given by these steps:</p>

  <ol><li><p>If <var>document</var>'s <a href=#node-navigable id=related-navigable-collections:node-navigable-4>node navigable</a> is null, then return the empty
   list.<li><p>Let <var>navigables</var> be new <a id=related-navigable-collections:list-3 href=https://infra.spec.whatwg.org/#list data-x-internal=list>list</a>.<li><p>Let <var>navigableContainers</var> be a <a id=related-navigable-collections:list-4 href=https://infra.spec.whatwg.org/#list data-x-internal=list>list</a> of all <a href=https://dom.spec.whatwg.org/#concept-tree-descendant id=related-navigable-collections:descendant data-x-internal=descendant>descendants</a> of <var>document</var> that are <a href=#navigable-container id=related-navigable-collections:navigable-container-2>navigable containers</a>, in <a id=related-navigable-collections:tree-order href=https://dom.spec.whatwg.org/#concept-tree-order data-x-internal=tree-order>tree order</a>.<li>
    <p><a href=https://infra.spec.whatwg.org/#list-iterate id=related-navigable-collections:list-iterate-2 data-x-internal=list-iterate>For each</a> <var>navigableContainer</var> of
    <var>navigableContainers</var>:</p>

    <ol><li><p>If <var>navigableContainer</var>'s <a href=#content-navigable id=related-navigable-collections:content-navigable-3>content navigable</a> is null, then
     <a id=related-navigable-collections:continue href=https://infra.spec.whatwg.org/#iteration-continue data-x-internal=continue>continue</a>.<li><p><a href=https://infra.spec.whatwg.org/#list-append id=related-navigable-collections:list-append-2 data-x-internal=list-append>Append</a> <var>navigableContainer</var>'s <a href=#content-navigable id=related-navigable-collections:content-navigable-4>content
     navigable</a> to <var>navigables</var>.</ol>
   <li><p>Return <var>navigables</var>.</ol>


  <h5 id=garbage-collection-and-browsing-contexts><span class=secno>7.3.1.6</span> Navigable destruction<a href=#garbage-collection-and-browsing-contexts class=self-link></a></h5>

  <p>To <dfn id=destroy-a-child-navigable>destroy a child navigable</dfn> given a <a href=#navigable-container id=garbage-collection-and-browsing-contexts:navigable-container>navigable container</a>
  <var>container</var>:</p>

  <ol><li><p>Let <var>navigable</var> be <var>container</var>'s <a href=#content-navigable id=garbage-collection-and-browsing-contexts:content-navigable>content
   navigable</a>.<li><p>If <var>navigable</var> is null, then return.<li><p>Set <var>container</var>'s <a href=#content-navigable id=garbage-collection-and-browsing-contexts:content-navigable-2>content navigable</a> to null.<li><p><a id=garbage-collection-and-browsing-contexts:inform-the-navigation-api-about-child-navigable-destruction href=nav-history-apis.html#inform-the-navigation-api-about-child-navigable-destruction>Inform the navigation API about child navigable destruction</a> given
   <var>navigable</var>.<li><p><a id=garbage-collection-and-browsing-contexts:destroy-a-document-and-its-descendants href=document-lifecycle.html#destroy-a-document-and-its-descendants>Destroy a document and its descendants</a> given <var>navigable</var>'s <a href=#nav-document id=garbage-collection-and-browsing-contexts:nav-document>active document</a>.<li><p>Let <var>parentDocState</var> be <var>container</var>'s <a href=#node-navigable id=garbage-collection-and-browsing-contexts:node-navigable>node navigable</a>'s
   <a href=#nav-active-history-entry id=garbage-collection-and-browsing-contexts:nav-active-history-entry>active session history entry</a>'s <a href=browsing-the-web.html#she-document-state id=garbage-collection-and-browsing-contexts:she-document-state>document state</a>.<li><p><a href=https://infra.spec.whatwg.org/#list-remove id=garbage-collection-and-browsing-contexts:list-remove data-x-internal=list-remove>Remove</a> the <a id=garbage-collection-and-browsing-contexts:nested-history href=browsing-the-web.html#nested-history>nested history</a> from
   <var>parentDocState</var>'s <a href=browsing-the-web.html#document-state-nested-histories id=garbage-collection-and-browsing-contexts:document-state-nested-histories>nested
   histories</a> whose <a href=browsing-the-web.html#nested-history-id id=garbage-collection-and-browsing-contexts:nested-history-id>id</a> equals
   <var>navigable</var>'s <a href=#nav-id id=garbage-collection-and-browsing-contexts:nav-id>id</a>.<li><p>Let <var>traversable</var> be <var>container</var>'s <a href=#node-navigable id=garbage-collection-and-browsing-contexts:node-navigable-2>node navigable</a>'s <a href=#nav-traversable id=garbage-collection-and-browsing-contexts:nav-traversable>traversable navigable</a>.<li>
    <p><a href=browsing-the-web.html#tn-append-session-history-traversal-steps id=garbage-collection-and-browsing-contexts:tn-append-session-history-traversal-steps>Append the following session
    history traversal steps</a> to <var>traversable</var>:</p>

    <ol><li><p><a id=garbage-collection-and-browsing-contexts:update-for-navigable-creation/destruction href=browsing-the-web.html#update-for-navigable-creation/destruction>Update for navigable creation/destruction</a> given
     <var>traversable</var>.</ol>
   <li><p>Invoke <a id=garbage-collection-and-browsing-contexts:webdriver-bidi-navigable-destroyed href=https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigable-destroyed data-x-internal=webdriver-bidi-navigable-destroyed>WebDriver BiDi navigable destroyed</a> with <var>navigable</var>.</ol>

  <p>To <dfn id=destroy-a-top-level-traversable>destroy</dfn> a <a href=#top-level-traversable id=garbage-collection-and-browsing-contexts:top-level-traversable>top-level
  traversable</a> <var>traversable</var>:</p>

  <ol><li><p>Let <var>browsingContext</var> be <var>traversable</var>'s <a href=#nav-bc id=garbage-collection-and-browsing-contexts:nav-bc>active browsing context</a>.<li>
    <p><a href=https://infra.spec.whatwg.org/#list-iterate id=garbage-collection-and-browsing-contexts:list-iterate data-x-internal=list-iterate>For each</a> <var>historyEntry</var> in
    <var>traversable</var>'s <a href=#tn-session-history-entries id=garbage-collection-and-browsing-contexts:tn-session-history-entries>session history
    entries</a> <span class=XXX>in what order?</span>:</p>

    <ol><li><p>Let <var>document</var> be <var>historyEntry</var>'s <a href=browsing-the-web.html#she-document id=garbage-collection-and-browsing-contexts:she-document>document</a>.<li><p>If <var>document</var> is not null, then <a id=garbage-collection-and-browsing-contexts:destroy-a-document-and-its-descendants-2 href=document-lifecycle.html#destroy-a-document-and-its-descendants>destroy a document and its
     descendants</a> given <var>document</var>.</ol>
   <li><p><a href=#bcg-remove id=garbage-collection-and-browsing-contexts:bcg-remove>Remove</a> <var>browsingContext</var>.<li><p>Remove <var>traversable</var> from the user interface (e.g., close or hide its tab in
   a tabbed browser).<li><p><a href=https://infra.spec.whatwg.org/#list-remove id=garbage-collection-and-browsing-contexts:list-remove-2 data-x-internal=list-remove>Remove</a> <var>traversable</var> from the user agent's
   <a href=#top-level-traversable-set id=garbage-collection-and-browsing-contexts:top-level-traversable-set>top-level traversable set</a>.<li><p>Invoke <a id=garbage-collection-and-browsing-contexts:webdriver-bidi-navigable-destroyed-2 href=https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigable-destroyed data-x-internal=webdriver-bidi-navigable-destroyed>WebDriver BiDi navigable destroyed</a> with <var>traversable</var>.</ol>

  <p>User agents may <a href=#destroy-a-top-level-traversable id=garbage-collection-and-browsing-contexts:destroy-a-top-level-traversable>destroy a top-level traversable</a> at any time (typically, <a href=speculative-loading.html#nav-traversal-ui>in response to user requests</a>).</p>

  <p id=closing-browsing-contexts><span id=close-a-browsing-context></span>To <dfn data-dfn-for="top-level traversable" id=close-a-top-level-traversable data-export="">close</dfn> a <a href=#top-level-traversable id=garbage-collection-and-browsing-contexts:top-level-traversable-2>top-level traversable</a> <var>traversable</var>:</p>

  <ol><li><p>If <var>traversable</var>'s <a href=#is-closing id=garbage-collection-and-browsing-contexts:is-closing>is closing</a> is true, then return.<li><p><a href=#definitely-close-a-top-level-traversable id=garbage-collection-and-browsing-contexts:definitely-close-a-top-level-traversable>Definitely close</a>
   <var>traversable</var>.</ol>

  <p>To <dfn id=definitely-close-a-top-level-traversable>definitely close</dfn> a
  <a href=#top-level-traversable id=garbage-collection-and-browsing-contexts:top-level-traversable-3>top-level traversable</a> <var>traversable</var>:</p>

  <ol><li><p>Let <var>toUnload</var> be <var>traversable</var>'s <a href=#nav-document id=garbage-collection-and-browsing-contexts:nav-document-2>active
   document</a>'s <a href=#inclusive-descendant-navigables id=garbage-collection-and-browsing-contexts:inclusive-descendant-navigables>inclusive descendant navigables</a>.<li><p>If the result of <a id=garbage-collection-and-browsing-contexts:checking-if-unloading-is-canceled href=browsing-the-web.html#checking-if-unloading-is-canceled>checking if unloading is canceled</a> for <var>toUnload</var> is
   not "<code>continue</code>", then return.<li>
    <p><a href=browsing-the-web.html#tn-append-session-history-traversal-steps id=garbage-collection-and-browsing-contexts:tn-append-session-history-traversal-steps-2>Append the following session history
    traversal steps</a> to <var>traversable</var>:</p>

    <ol><li><p>Let <var>afterAllUnloads</var> be an algorithm step which <a href=#destroy-a-top-level-traversable id=garbage-collection-and-browsing-contexts:destroy-a-top-level-traversable-2>destroys</a> <var>traversable</var>.<li><p><a id=garbage-collection-and-browsing-contexts:unload-a-document-and-its-descendants href=document-lifecycle.html#unload-a-document-and-its-descendants>Unload a document and its descendants</a> given <var>traversable</var>'s <a href=#nav-document id=garbage-collection-and-browsing-contexts:nav-document-3>active document</a>, null, and <var>afterAllUnloads</var>.</ol>
   </ol>

  <p class=note>The <a href=#close-a-top-level-traversable id=garbage-collection-and-browsing-contexts:close-a-top-level-traversable>close</a> vs. <a href=#definitely-close-a-top-level-traversable id=garbage-collection-and-browsing-contexts:definitely-close-a-top-level-traversable-2>definitely close</a> separation allows other
  specifications to call <a href=#close-a-top-level-traversable id=garbage-collection-and-browsing-contexts:close-a-top-level-traversable-2>close</a> and have it be a
  no-op if the top-level traversable is already closing due to JavaScript code calling <code id=garbage-collection-and-browsing-contexts:dom-window-close><a href=nav-history-apis.html#dom-window-close>window.close()</a></code>.</p>


  <h5 id=navigable-target-names><span class=secno>7.3.1.7</span> <span id=browsing-context-names></span>Navigable target names<a href=#navigable-target-names class=self-link></a></h5>

  <p><a href=#navigable id=navigable-target-names:navigable>Navigables</a> can be given <a href=#nav-target id=navigable-target-names:nav-target>target
  names</a>, which are strings allowing certain APIs (such as <code id=navigable-target-names:dom-open><a href=nav-history-apis.html#dom-open>window.open()</a></code> or the <code id=navigable-target-names:the-a-element><a href=text-level-semantics.html#the-a-element>a</a></code> element's <code id=navigable-target-names:attr-hyperlink-target><a href=links.html#attr-hyperlink-target>target</a></code> attribute) to target <a href=browsing-the-web.html#navigate id=navigable-target-names:navigate>navigations</a> at that navigable.</p>

  <p id=valid-browsing-context-name>A <dfn id=valid-navigable-target-name>valid navigable target name</dfn> is any string with at
  least one character that does not contain both an <a id=navigable-target-names:ascii-tab-or-newline href=https://infra.spec.whatwg.org/#ascii-tab-or-newline data-x-internal=ascii-tab-or-newline>ASCII tab or newline</a> and a U+003C
  (&lt;), and it does not start with a U+005F (_). (Names starting with a U+005F (_) are reserved
  for special keywords.)</p>

  <p id=valid-browsing-context-name-or-keyword>A <dfn id=valid-navigable-target-name-or-keyword>valid navigable target name or
  keyword</dfn> is any string that is either a <a href=#valid-navigable-target-name id=navigable-target-names:valid-navigable-target-name>valid navigable target name</a> or that is
  an <a id=navigable-target-names:ascii-case-insensitive href=https://infra.spec.whatwg.org/#ascii-case-insensitive data-x-internal=ascii-case-insensitive>ASCII case-insensitive</a> match for one of: <code>_blank</code>, <code>_self</code>, <code>_parent</code>, or <code>_top</code>.</p>

  <p>These values have different meanings based on whether the page is sandboxed or not, as
  summarized in the following (non-normative) table. In this table, "current" means the
  <a href=#navigable id=navigable-target-names:navigable-2>navigable</a> that the link or script is in, "parent" means the <a href=#nav-parent id=navigable-target-names:nav-parent>parent</a> of the <a href=#navigable id=navigable-target-names:navigable-3>navigable</a> that the link or script is in,
  "top" means the <a href=#nav-top id=navigable-target-names:nav-top>top-level traversable</a> of the <a href=#navigable id=navigable-target-names:navigable-4>navigable</a>
  that the link or script is in, "new" means a new <a href=#traversable-navigable id=navigable-target-names:traversable-navigable>traversable navigable</a> with a null
  <a href=#nav-parent id=navigable-target-names:nav-parent-2>parent</a> (which may use an <a href=#auxiliary-browsing-context id=navigable-target-names:auxiliary-browsing-context>auxiliary browsing
  context</a>, subject to various user preferences and user agent policies), "none" means that
  nothing will happen, and "maybe new" means the same as "new" if the "<code id=navigable-target-names:attr-iframe-sandbox-allow-popups><a href=browsers.html#attr-iframe-sandbox-allow-popups>allow-popups</a></code>" keyword is also specified on the
  <code id=navigable-target-names:attr-iframe-sandbox><a href=iframe-embed-object.html#attr-iframe-sandbox>sandbox</a></code> attribute (or if the user overrode the
  sandboxing), and the same as "none" otherwise.</p>

  <table><thead><tr><th rowspan=2>Keyword
     <th rowspan=2>Ordinary effect
     <th colspan=2>Effect in an <code id=navigable-target-names:the-iframe-element><a href=iframe-embed-object.html#the-iframe-element>iframe</a></code> with...
    <tr><th><code>sandbox=""</code>
     <th><code>sandbox="allow-top-navigation"</code>

   <tbody><tr><td>none specified, for links and form submissions 
     <td>current
     <td>current
     <td>current

    <tr><td>empty string
     <td>current
     <td>current
     <td>current

    <tr><td><code>_blank</code>
     <td>new
     <td>maybe new
     <td>maybe new

    <tr><td><code>_self</code>
     <td>current
     <td>current
     <td>current

    <tr><td><code>_parent</code> if there isn't a parent
     <td>current
     <td>current
     <td>current

    <tr><td><code>_parent</code> if parent is also top
     <td>parent/top
     <td>none
     <td>parent/top

    <tr><td><code>_parent</code> if there is one and it's not top
     <td>parent
     <td>none
     <td>none

    <tr><td><code>_top</code> if top is current
     <td>current
     <td>current
     <td>current

    <tr><td><code>_top</code> if top is not current
     <td>top
     <td>none
     <td>top

    <tr><td>name that doesn't exist
     <td>new
     <td>maybe new
     <td>maybe new

    <tr><td>name that exists and is a descendant
     <td>specified descendant
     <td>specified descendant
     <td>specified descendant

    <tr><td>name that exists and is current
     <td>current
     <td>current
     <td>current

    <tr><td>name that exists and is an ancestor that is top
     <td>specified ancestor
     <td>none
     <td>specified ancestor/top

    <tr><td>name that exists and is an ancestor that is not top
     <td>specified ancestor
     <td>none
     <td>none

    <tr><td>other name that exists with common top
     <td>specified
     <td>none
     <td>none

    <tr><td>name that exists with different top, if <a href=#familiar-with id=navigable-target-names:familiar-with>familiar</a> and <a id=navigable-target-names:one-permitted-sandboxed-navigator href=browsers.html#one-permitted-sandboxed-navigator>one permitted sandboxed navigator</a>
     <td>specified
     <td>specified
     <td>specified

    <tr><td>name that exists with different top, if <a href=#familiar-with id=navigable-target-names:familiar-with-2>familiar</a> but not <a id=navigable-target-names:one-permitted-sandboxed-navigator-2 href=browsers.html#one-permitted-sandboxed-navigator>one permitted sandboxed navigator</a>
     <td>specified
     <td>none
     <td>none

    <tr><td>name that exists with different top, not <a href=#familiar-with id=navigable-target-names:familiar-with-3>familiar</a>
     <td>new
     <td>maybe new
     <td>maybe new

  </table>

  <p class=tablenote><small>Most of the restrictions on sandboxed browsing contexts are applied by
  other algorithms, e.g. the <a href=browsing-the-web.html#navigate id=navigable-target-names:navigate-2>navigation</a> algorithm, not <a href=#the-rules-for-choosing-a-navigable id=navigable-target-names:the-rules-for-choosing-a-navigable>the
  rules for choosing a navigable</a> given below.</small></p>

  <hr>

  <p>To <dfn id=find-a-navigable-by-target-name>find a navigable by target name</dfn> given a string <var>name</var> and a
  <a href=#navigable id=navigable-target-names:navigable-5>navigable</a> <var>currentNavigable</var>:</p>

  <ol><li><p>Let <var>currentDocument</var> be <var>currentNavigable</var>'s <a href=#nav-document id=navigable-target-names:nav-document>active document</a>.<li><p>Let <var>sourceSnapshotParams</var> be the result of <a id=navigable-target-names:snapshotting-source-snapshot-params href=browsing-the-web.html#snapshotting-source-snapshot-params>snapshotting source snapshot
   params</a> given <var>currentDocument</var>.<li>
    <p>Let <var>subtreesToSearch</var> be an <a id=navigable-target-names:implementation-defined href=https://infra.spec.whatwg.org/#implementation-defined data-x-internal=implementation-defined>implementation-defined</a> choice of one of
    the following:</p>

    <ul><li><p>« <var>currentNavigable</var>'s <a href=#nav-traversable id=navigable-target-names:nav-traversable>traversable
     navigable</a>, <var>currentNavigable</var> »<li><p>the <a href=#inclusive-ancestor-navigables id=navigable-target-names:inclusive-ancestor-navigables>inclusive ancestor navigables</a> of <var>currentDocument</var></ul>

    <p class=XXX><a href=https://github.com/whatwg/html/issues/10848>Issue #10848</a> tracks
    settling on one of these two possibilities, to achieve interoperability.</p>
   <li>
    <p><a href=https://infra.spec.whatwg.org/#list-iterate id=navigable-target-names:list-iterate data-x-internal=list-iterate>For each</a> <var>subtreeToSearch</var> of
    <var>subtreesToSearch</var>, in reverse order:</p>

    <ol><li><p>Let <var>documentToSearch</var> be <var>subtreeToSearch</var>'s <a href=#nav-document id=navigable-target-names:nav-document-2>active document</a>.<li>
      <p><a href=https://infra.spec.whatwg.org/#list-iterate id=navigable-target-names:list-iterate-2 data-x-internal=list-iterate>For each</a> <var>navigable</var> of the <a href=#inclusive-descendant-navigables id=navigable-target-names:inclusive-descendant-navigables>inclusive
      descendant navigables</a> of <var>documentToSearch</var>:</p>

      <ol><li>
        <p>If <var>currentNavigable</var> is not <a id=navigable-target-names:allowed-to-navigate href=browsing-the-web.html#allowed-to-navigate>allowed by sandboxing to navigate</a>
        <var>navigable</var> given <var>sourceSnapshotParams</var>, then optionally
        <a id=navigable-target-names:continue href=https://infra.spec.whatwg.org/#iteration-continue data-x-internal=continue>continue</a>.</p>

        <p class=XXX><a href=https://github.com/whatwg/html/issues/10849>Issue #10849</a> tracks
        making this check required, to achieve interoperability.</p>
       <li><p>If <var>navigable</var>'s <a href=#nav-target id=navigable-target-names:nav-target-2>target name</a> is
       <var>name</var>, then return <var>navigable</var>.</ol>
     </ol>
   <li><p>Let <var>currentTopLevelBrowsingContext</var> be <var>currentNavigable</var>'s <a href=#nav-bc id=navigable-target-names:nav-bc>active browsing context</a>'s <a href=#bc-tlbc id=navigable-target-names:bc-tlbc>top-level browsing
   context</a>.<li><p>Let <var>group</var> be <var>currentTopLevelBrowsingContext</var>'s <a href=#tlbc-group id=navigable-target-names:tlbc-group>group</a>.<li>
    <p><a href=https://infra.spec.whatwg.org/#list-iterate id=navigable-target-names:list-iterate-3 data-x-internal=list-iterate>For each</a> <var>topLevelBrowsingContext</var> of
    <var>group</var>'s <a href=#browsing-context-set id=navigable-target-names:browsing-context-set>browsing context set</a>, in an <a id=navigable-target-names:implementation-defined-2 href=https://infra.spec.whatwg.org/#implementation-defined data-x-internal=implementation-defined>implementation-defined</a>
    order (the user agent should pick a consistent ordering, such as the most recently opened, most
    recently focused, or more closely related):</p>

    <p class=XXX><a href=https://github.com/whatwg/html/issues/10850>Issue #10850</a> tracks
    picking a specific ordering, to achieve interoperability.</p>

    <ol><li><p>If <var>currentTopLevelBrowsingContext</var> is <var>topLevelBrowsingContext</var>, then
     <a id=navigable-target-names:continue-2 href=https://infra.spec.whatwg.org/#iteration-continue data-x-internal=continue>continue</a>.<li><p>Let <var>documentToSearch</var> be <var>topLevelBrowsingContext</var>'s <a href=#active-document id=navigable-target-names:active-document>active
     document</a>.<li>
      <p><a href=https://infra.spec.whatwg.org/#list-iterate id=navigable-target-names:list-iterate-4 data-x-internal=list-iterate>For each</a> <var>navigable</var> of the <a href=#inclusive-descendant-navigables id=navigable-target-names:inclusive-descendant-navigables-2>inclusive
      descendant navigables</a> of <var>documentToSearch</var>:</p>

      <ol><li><p>If <var>currentNavigable</var>'s <a href=#nav-bc id=navigable-target-names:nav-bc-2>active browsing context</a>
       is not <a href=#familiar-with id=navigable-target-names:familiar-with-4>familiar with</a> <var>navigable</var>'s <a href=#nav-bc id=navigable-target-names:nav-bc-3>active
       browsing context</a>, then <a id=navigable-target-names:continue-3 href=https://infra.spec.whatwg.org/#iteration-continue data-x-internal=continue>continue</a>.<li>
        <p>If <var>currentNavigable</var> is not <a id=navigable-target-names:allowed-to-navigate-2 href=browsing-the-web.html#allowed-to-navigate>allowed by sandboxing to navigate</a>
        <var>navigable</var> given <var>sourceSnapshotParams</var>, then optionally
        <a id=navigable-target-names:continue-4 href=https://infra.spec.whatwg.org/#iteration-continue data-x-internal=continue>continue</a>.</p>


        <p class=XXX><a href=https://github.com/whatwg/html/issues/10849>Issue #10849</a> tracks
        making this check required, to achieve interoperability.</p>
       <li><p>If <var>navigable</var>'s <a href=#nav-target id=navigable-target-names:nav-target-3>target name</a> is
       <var>name</var>, then return <var>navigable</var>.</ol>
     </ol>
   <li><p>Return null.</ol>

  <p id=the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name><dfn id=the-rules-for-choosing-a-navigable>The rules
  for choosing a navigable</dfn>, given a string <var>name</var>, a <a href=#navigable id=navigable-target-names:navigable-6>navigable</a>
  <var>currentNavigable</var>, and a boolean <var>noopener</var> are as follows:</p>

  <ol><li><p>Let <var>chosen</var> be null.<li><p>Let <var>windowType</var> be "<code>existing or none</code>".<li><p>Let <var>sandboxingFlagSet</var> be <var>currentNavigable</var>'s <a href=#nav-document id=navigable-target-names:nav-document-3>active document</a>'s <a id=navigable-target-names:active-sandboxing-flag-set href=browsers.html#active-sandboxing-flag-set>active sandboxing flag set</a>.<li><p>If <var>name</var> is the empty string or an <a id=navigable-target-names:ascii-case-insensitive-2 href=https://infra.spec.whatwg.org/#ascii-case-insensitive data-x-internal=ascii-case-insensitive>ASCII case-insensitive</a> match
   for "<code>_self</code>", then set <var>chosen</var> to
   <var>currentNavigable</var>.<li><p>Otherwise, if <var>name</var> is an <a id=navigable-target-names:ascii-case-insensitive-3 href=https://infra.spec.whatwg.org/#ascii-case-insensitive data-x-internal=ascii-case-insensitive>ASCII case-insensitive</a> match for "<code>_parent</code>", set <var>chosen</var> to <var>currentNavigable</var>'s <a href=#nav-parent id=navigable-target-names:nav-parent-3>parent</a>, if any, and <var>currentNavigable</var> otherwise.<li><p>Otherwise, if <var>name</var> is an <a id=navigable-target-names:ascii-case-insensitive-4 href=https://infra.spec.whatwg.org/#ascii-case-insensitive data-x-internal=ascii-case-insensitive>ASCII case-insensitive</a> match for "<code>_top</code>", set <var>chosen</var> to <var>currentNavigable</var>'s <a href=#nav-traversable id=navigable-target-names:nav-traversable-2>traversable navigable</a>.<li><p>Otherwise, if <var>name</var> is not an <a id=navigable-target-names:ascii-case-insensitive-5 href=https://infra.spec.whatwg.org/#ascii-case-insensitive data-x-internal=ascii-case-insensitive>ASCII case-insensitive</a> match for
   "<code>_blank</code>" and <var>noopener</var> is false, then set <var>chosen</var> to
   the result of <a href=#find-a-navigable-by-target-name id=navigable-target-names:find-a-navigable-by-target-name>finding a navigable by target
   name</a> given <var>name</var> and <var>currentNavigable</var>.<li>
    <p>If <var>chosen</var> is null, then a new <a href=#top-level-traversable id=navigable-target-names:top-level-traversable>top-level traversable</a> is being
    requested, and what happens depends on the user agent's configuration and abilities — it
    is determined by the rules given for the first applicable option from the following list:</p>

    <dl class=switch><dt id=popup-blocker>If <var>currentNavigable</var>'s <a href=#nav-window id=navigable-target-names:nav-window>active
     window</a> does not have <a id=navigable-target-names:transient-activation href=interaction.html#transient-activation>transient activation</a> and the user agent has been
     configured to not show popups (i.e., the user agent has a "popup blocker" enabled)<dd><p>The user agent may inform the user that a popup has been blocked.<dt id=sandboxWindowOpen>If <var>sandboxingFlagSet</var> has the <a id=navigable-target-names:sandboxed-auxiliary-navigation-browsing-context-flag href=browsers.html#sandboxed-auxiliary-navigation-browsing-context-flag>sandboxed auxiliary
     navigation browsing context flag</a> set<dd><p>The user agent may report to a developer console that a popup has been blocked.<dt>If the user agent has been configured such that in this instance it will create a new <a href=#top-level-traversable id=navigable-target-names:top-level-traversable-2>top-level traversable</a><dd>
      <ol><li><p><a id=navigable-target-names:consume-user-activation href=interaction.html#consume-user-activation>Consume user activation</a> of <var>currentNavigable</var>'s <a href=#nav-window id=navigable-target-names:nav-window-2>active window</a>.<li><p>Set <var>windowType</var> to "<code>new and unrestricted</code>".<li><p>Let <var>currentDocument</var> be <var>currentNavigable</var>'s <a href=#nav-document id=navigable-target-names:nav-document-4>active document</a>.<li>
        <p>If <var>currentDocument</var>'s <a href=dom.html#concept-document-coop id=navigable-target-names:concept-document-coop>opener
        policy</a>'s <a href=browsers.html#coop-struct-value id=navigable-target-names:coop-struct-value>value</a> is "<code id=navigable-target-names:coop-same-origin><a href=browsers.html#coop-same-origin>same-origin</a></code>" or "<code id=navigable-target-names:coop-same-origin-plus-coep><a href=browsers.html#coop-same-origin-plus-coep>same-origin-plus-COEP</a></code>", and
        <var>currentDocument</var>'s <a href=https://dom.spec.whatwg.org/#concept-document-origin id=navigable-target-names:concept-document-origin data-x-internal=concept-document-origin>origin</a> is not
        <a id=navigable-target-names:same-origin href=browsers.html#same-origin>same origin</a> with <var>currentDocument</var>'s <a id=navigable-target-names:relevant-settings-object href=webappapis.html#relevant-settings-object>relevant settings
        object</a>'s <a id=navigable-target-names:concept-environment-top-level-origin href=webappapis.html#concept-environment-top-level-origin>top-level origin</a>, then:</p>

        <ol><li><p>Set <var>noopener</var> to true.<li><p>Set <var>name</var> to "<code>_blank</code>".<li><p>Set <var>windowType</var> to "<code>new with no opener</code>".</p>
        </ol>

        <p class=note>In the presence of an <a id=navigable-target-names:cross-origin-opener-policy href=browsers.html#cross-origin-opener-policy>opener policy</a>, nested documents that are
        cross-origin with their top-level browsing context's active document always set
        <var>noopener</var> to true.</p>
       <li><p>Let <var>targetName</var> be the empty string.<li><p>If <var>name</var> is not an <a id=navigable-target-names:ascii-case-insensitive-6 href=https://infra.spec.whatwg.org/#ascii-case-insensitive data-x-internal=ascii-case-insensitive>ASCII case-insensitive</a> match for "<code>_blank</code>", then set <var>targetName</var> to <var>name</var>.<li id=noopener><p>If <var>noopener</var> is true, then set <var>chosen</var> to the
       result of <a href=#creating-a-new-top-level-traversable id=navigable-target-names:creating-a-new-top-level-traversable>creating a new top-level traversable</a> given null,
       <var>targetName</var>, and <var>currentNavigable</var>.<li>
        <p>Otherwise:</p>

        <ol><li><p>Set <var>chosen</var> to the result of <a href=#creating-a-new-top-level-traversable id=navigable-target-names:creating-a-new-top-level-traversable-2>creating a new top-level
         traversable</a> given <var>currentNavigable</var>'s <a href=#nav-bc id=navigable-target-names:nav-bc-4>active
         browsing context</a>, <var>targetName</var>, and <var>currentNavigable</var>.<li><p>If <var>sandboxingFlagSet</var>'s <a id=navigable-target-names:sandboxed-navigation-browsing-context-flag href=browsers.html#sandboxed-navigation-browsing-context-flag>sandboxed navigation browsing context
         flag</a> is set, then set <var>chosen</var>'s <a href=#nav-bc id=navigable-target-names:nav-bc-5>active browsing
         context</a>'s <a id=navigable-target-names:one-permitted-sandboxed-navigator-3 href=browsers.html#one-permitted-sandboxed-navigator>one permitted sandboxed navigator</a> to
         <var>currentNavigable</var>'s <a href=#nav-bc id=navigable-target-names:nav-bc-6>active browsing
         context</a>.</ol>
       <li><p>If <var>sandboxingFlagSet</var>'s <a id=navigable-target-names:sandbox-propagates-to-auxiliary-browsing-contexts-flag href=browsers.html#sandbox-propagates-to-auxiliary-browsing-contexts-flag>sandbox propagates to auxiliary browsing
       contexts flag</a> is set, then all the flags that are set in <var>sandboxingFlagSet</var>
       must be set in <var>chosen</var>'s <a href=#nav-bc id=navigable-target-names:nav-bc-7>active browsing context</a>'s
       <a id=navigable-target-names:popup-sandboxing-flag-set href=browsers.html#popup-sandboxing-flag-set>popup sandboxing flag set</a>.<li><p>Set <var>chosen</var>'s <a href=#is-created-by-web-content id=navigable-target-names:is-created-by-web-content>is created by web content</a> to true.</ol>

      <p class=note>If the newly created <a href=#navigable id=navigable-target-names:navigable-7>navigable</a> <var>chosen</var> is immediately
      <a href=browsing-the-web.html#navigate id=navigable-target-names:navigate-3>navigated</a>, then the navigation will be done as a "<code id=navigable-target-names:navigationhistorybehavior-replace><a href=browsing-the-web.html#navigationhistorybehavior-replace>replace</a></code>" navigation.</p>
     <dt>If the user agent has been configured such that in this instance it will choose <var>currentNavigable</var><dd><p>Set <var>chosen</var> to <var>currentNavigable</var>.<dt>If the user agent has been configured such that in this instance it will not find a navigable<dd><p>Do nothing.</dl>

    <p class=note>User agents are encouraged to provide a way for users to configure the user
    agent to always choose <var>currentNavigable</var>.</p>
   <li><p>Return <var>chosen</var> and <var>windowType</var>.</ol>


  <h4 id=windows><span class=secno>7.3.2</span> Browsing contexts<a href=#windows class=self-link></a></h4>

  <p>A <dfn id=browsing-context data-export="">browsing context</dfn> is a programmatic representation of a series of documents,
  multiple of which can live within a single <a href=#navigable id=windows:navigable>navigable</a>. Each <a href=#browsing-context id=windows:browsing-context>browsing
  context</a> has a corresponding <code id=windows:windowproxy><a href=nav-history-apis.html#windowproxy>WindowProxy</a></code> object, as well as the following:</p>

  <ul><li><p>An <dfn id=opener-browsing-context data-export="">opener browsing context</dfn>, a <a href=#browsing-context id=windows:browsing-context-2>browsing context</a> or null,
   initially null.<li><p>An <dfn id=opener-origin-at-creation>opener origin at creation</dfn>, an
   <a id=windows:concept-origin href=browsers.html#concept-origin>origin</a> or null, initially null.</p>

   <li>
    <p>An <dfn id=is-popup>is popup</dfn> boolean, initially false.</p>

    <p class=note>The only mandatory impact in this specification of <a href=#is-popup id=windows:is-popup>is popup</a> is on
    the <code id=windows:dom-barprop-visible><a href=nav-history-apis.html#dom-barprop-visible>visible</a></code> getter of the relevant
    <code id=windows:barprop><a href=nav-history-apis.html#barprop>BarProp</a></code> objects. However, user agents might also use it for <a href=speculative-loading.html#nav-traversal-ui>user interface considerations</a>.</p>
   <li><p>An <dfn id=is-auxiliary>is auxiliary</dfn> boolean, initially false.<li><p>An <dfn id=browsing-context-initial-url>initial URL</dfn>, a <a id=windows:url href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> or
   null, initially null.<li><p>A <dfn id=virtual-browsing-context-group-id>virtual browsing context group ID</dfn>
   integer, initially 0. This is used by <a href=browsers.html#coop-struct-report-only-value id=windows:coop-struct-report-only-value>opener policy
   reporting</a>, to keep track of the browsing context group switches that would have happened
   if the report-only policy had been enforced.</ul>

  <p>A <a href=#browsing-context id=windows:browsing-context-3>browsing context</a>'s <dfn id=active-window>active window</dfn> is its <code id=windows:windowproxy-2><a href=nav-history-apis.html#windowproxy>WindowProxy</a></code>
  object's <a href=nav-history-apis.html#concept-windowproxy-window id=windows:concept-windowproxy-window>[[Window]]</a> internal slot value. A
  <a href=#browsing-context id=windows:browsing-context-4>browsing context</a>'s <dfn id=active-document>active document</dfn> is its <a href=#active-window id=windows:active-window>active window</a>'s
  <a href=nav-history-apis.html#concept-document-window id=windows:concept-document-window>associated <code>Document</code></a>.</p>

  <p>A <a href=#browsing-context id=windows:browsing-context-5>browsing context</a>'s <dfn data-dfn-for="browsing context" id=bc-traversable data-export="">top-level traversable</dfn> is its <a href=#active-document id=windows:active-document>active document</a>'s
  <a href=#node-navigable id=windows:node-navigable>node navigable</a>'s <a href=#nav-top id=windows:nav-top>top-level traversable</a>.</p>

  <p>A <a href=#browsing-context id=windows:browsing-context-6>browsing context</a> whose <a href=#is-auxiliary id=windows:is-auxiliary>is auxiliary</a> is true is known as an <dfn id=auxiliary-browsing-context data-export="">auxiliary browsing context</dfn>. Auxiliary browsing contexts are always <a href=#top-level-browsing-context id=windows:top-level-browsing-context>top-level browsing contexts</a>.</p>

  <p class=XXX>It's unclear whether a separate <a href=#is-auxiliary id=windows:is-auxiliary-2>is auxiliary</a> concept is necessary. In
  <a href=https://github.com/whatwg/html/issues/5680>issue #5680</a>, it is indicated that we may
  be able to simplify this by using whether or not the <a href=#opener-browsing-context id=windows:opener-browsing-context>opener browsing context</a> is
  null.</p>

  <p id=warning-avoid-using-bcs class=warning>Modern specifications should avoid using the
  <a href=#browsing-context id=windows:browsing-context-7>browsing context</a> concept in most cases, unless they are dealing with the subtleties
  of <a href=browsers.html#browsing-context-group-switches-due-to-cross-origin-opener-policy>browsing context
  group switches</a> and <a href=#agent-cluster-map id=windows:agent-cluster-map>agent cluster allocation</a>. Instead,
  the <code id=windows:document><a href=dom.html#document>Document</a></code> and <a href=#navigable id=windows:navigable-2>navigable</a> concepts are usually more appropriate.</p>

  <hr>

  <p>A <dfn data-dfn-for=Document id=concept-document-bc data-lt="browsing context" data-export=""><code>Document</code>'s browsing context</dfn> is a <a href=#browsing-context id=windows:browsing-context-8>browsing context</a> or null,
  initially null.</p>

  <p class=note>A <code id=windows:document-2><a href=dom.html#document>Document</a></code> does not necessarily have a non-null <a href=#concept-document-bc id=windows:concept-document-bc>browsing context</a>. In particular, data mining tools are likely
  to never instantiate browsing contexts. A <code id=windows:document-3><a href=dom.html#document>Document</a></code> created using an API such as <code id=windows:dom-domimplementation-createdocument><a data-x-internal=dom-domimplementation-createdocument href=https://dom.spec.whatwg.org/#dom-domimplementation-createdocument>createDocument()</a></code> never has a non-null <a href=#concept-document-bc id=windows:concept-document-bc-2>browsing context</a>. And the <code id=windows:document-4><a href=dom.html#document>Document</a></code> originally
  created for an <code id=windows:the-iframe-element><a href=iframe-embed-object.html#the-iframe-element>iframe</a></code> element, which has since been <a href=infrastructure.html#remove-an-element-from-a-document id=windows:remove-an-element-from-a-document>removed from the document</a>, has no associated browsing context, since that
  browsing context was <a href=document-lifecycle.html#destroy-a-document id=windows:destroy-a-document>nulled out</a>.</p>

  <p class=note>In general, there is a 1-to-1 mapping from the <code id=windows:window><a href=nav-history-apis.html#window>Window</a></code> object to the
  <code id=windows:document-5><a href=dom.html#document>Document</a></code> object, as long as the <code id=windows:document-6><a href=dom.html#document>Document</a></code> object has a non-null <a href=#concept-document-bc id=windows:concept-document-bc-3>browsing context</a>. There is one exception. A
  <code id=windows:window-2><a href=nav-history-apis.html#window>Window</a></code> can be reused for the presentation of a second <code id=windows:document-7><a href=dom.html#document>Document</a></code> in the
  same <a href=#browsing-context id=windows:browsing-context-9>browsing context</a>, such that the mapping is then 1-to-2. This occurs when a
  <a href=#browsing-context id=windows:browsing-context-10>browsing context</a> is <a href=browsing-the-web.html#navigate id=windows:navigate>navigated</a> from the <a href=dom.html#is-initial-about:blank id=windows:is-initial-about:blank>initial <code>about:blank</code></a> <code id=windows:document-8><a href=dom.html#document>Document</a></code> to
  another, which will be done with <a href=browsing-the-web.html#navigationhistorybehavior-replace id=windows:navigationhistorybehavior-replace>replacement</a>.</p>

  <h5 id=creating-browsing-contexts><span class=secno>7.3.2.1</span> Creating browsing contexts<a href=#creating-browsing-contexts class=self-link></a></h5>

  <p>To <dfn id=creating-a-new-browsing-context>create a new browsing context and document</dfn>, given null or a <code id=creating-browsing-contexts:document><a href=dom.html#document>Document</a></code>
  object <var>creator</var>, null or an element <var>embedder</var>, and a <a href=#browsing-context-group id=creating-browsing-contexts:browsing-context-group>browsing context
  group</a> <var>group</var>:</p>

  

  <ol><li><p>Let <var>browsingContext</var> be a new <a href=#browsing-context id=creating-browsing-contexts:browsing-context>browsing context</a>.<li><p>Let <var>unsafeContextCreationTime</var> be the
   <a id=creating-browsing-contexts:unsafe-shared-current-time href=https://w3c.github.io/hr-time/#dfn-unsafe-shared-current-time data-x-internal=unsafe-shared-current-time>unsafe shared current time</a>.<li><p>Let <var>creatorOrigin</var> be null.</p>

   <li><p>Let <var>creatorBaseURL</var> be null.<li id=creator-browsing-context>
    <p>If <var>creator</var> is non-null, then:</p>

    <ol><li><p>Set <var>creatorOrigin</var> to <var>creator</var>'s <a href=https://dom.spec.whatwg.org/#concept-document-origin id=creating-browsing-contexts:concept-document-origin data-x-internal=concept-document-origin>origin</a>.<li><p>Set <var>creatorBaseURL</var> to <var>creator</var>'s <a id=creating-browsing-contexts:document-base-url href=urls-and-fetching.html#document-base-url>document base
     URL</a>.<li><p>Set <var>browsingContext</var>'s <a href=#virtual-browsing-context-group-id id=creating-browsing-contexts:virtual-browsing-context-group-id>virtual browsing context group ID</a> to
     <var>creator</var>'s <a href=#concept-document-bc id=creating-browsing-contexts:concept-document-bc>browsing context</a>'s <a href=#bc-tlbc id=creating-browsing-contexts:bc-tlbc>top-level browsing context</a>'s <a href=#virtual-browsing-context-group-id id=creating-browsing-contexts:virtual-browsing-context-group-id-2>virtual browsing context group ID</a>.</ol>
   <li><p>Let <var>sandboxFlags</var> be the result of <a id=creating-browsing-contexts:determining-the-creation-sandboxing-flags href=browsers.html#determining-the-creation-sandboxing-flags>determining the creation sandboxing
   flags</a> given <var>browsingContext</var> and <var>embedder</var>.<li id=about-blank-origin><p>Let <var>origin</var> be the result of <a href=#determining-the-origin id=creating-browsing-contexts:determining-the-origin>determining the
   origin</a> given <code id=creating-browsing-contexts:about:blank><a href=infrastructure.html#about:blank>about:blank</a></code>, <var>sandboxFlags</var>, and
   <var>creatorOrigin</var>.<li>
    <p>Let <var>permissionsPolicy</var> be the result of <a id=creating-browsing-contexts:creating-a-permissions-policy href=https://w3c.github.io/webappsec-feature-policy/#create-for-navigable data-x-internal=creating-a-permissions-policy>creating a permissions policy</a>
    given <var>embedder</var> and <var>origin</var>. <a href=references.html#refsPERMISSIONSPOLICY>[PERMISSIONSPOLICY]</a></p>
   <li><p>Let <var>agent</var> be the result of <a href=webappapis.html#obtain-similar-origin-window-agent id=creating-browsing-contexts:obtain-similar-origin-window-agent>obtaining a similar-origin window agent</a> given
   <var>origin</var>, <var>group</var>, and false.<li>
    <p>Let <var>realm execution context</var> be the result of <a id=creating-browsing-contexts:creating-a-new-javascript-realm href=webappapis.html#creating-a-new-javascript-realm>creating a new realm</a>
    given <var>agent</var> and the following customizations:</p>

    <ul><li><p>For the global object, create a new <code id=creating-browsing-contexts:window><a href=nav-history-apis.html#window>Window</a></code> object.<li><p>For the global <b>this</b> binding, use <var>browsingContext</var>'s
     <code id=creating-browsing-contexts:windowproxy><a href=nav-history-apis.html#windowproxy>WindowProxy</a></code> object.</ul>
   <li><p>Let <var>topLevelCreationURL</var> be <code id=creating-browsing-contexts:about:blank-2><a href=infrastructure.html#about:blank>about:blank</a></code> if <var>embedder</var> is
   null; otherwise <var>embedder</var>'s <a id=creating-browsing-contexts:relevant-settings-object href=webappapis.html#relevant-settings-object>relevant settings object</a>'s <a id=creating-browsing-contexts:concept-environment-top-level-creation-url href=webappapis.html#concept-environment-top-level-creation-url>top-level
   creation URL</a>.<li><p>Let <var>topLevelOrigin</var> be <var>origin</var> if <var>embedder</var> is null;
   otherwise <var>embedder</var>'s <a id=creating-browsing-contexts:relevant-settings-object-2 href=webappapis.html#relevant-settings-object>relevant settings object</a>'s <a id=creating-browsing-contexts:concept-environment-top-level-origin href=webappapis.html#concept-environment-top-level-origin>top-level
   origin</a>.<li><p><a id=creating-browsing-contexts:set-up-a-window-environment-settings-object href=nav-history-apis.html#set-up-a-window-environment-settings-object>Set up a window environment settings object</a> with <code id=creating-browsing-contexts:about:blank-3><a href=infrastructure.html#about:blank>about:blank</a></code>,
   <var>realm execution context</var>, null, <var>topLevelCreationURL</var>, and
   <var>topLevelOrigin</var>.<li><p>Let <var>loadTimingInfo</var> be a new <a id=creating-browsing-contexts:document-load-timing-info href=dom.html#document-load-timing-info>document load timing info</a> with
   its <a id=creating-browsing-contexts:navigation-start-time href=dom.html#navigation-start-time>navigation start time</a> set to the result of calling <a id=creating-browsing-contexts:coarsen-time href=https://w3c.github.io/hr-time/#dfn-coarsen-time data-x-internal=coarsen-time>coarsen time</a>
   with <var>unsafeContextCreationTime</var> and the new <a id=creating-browsing-contexts:environment-settings-object href=webappapis.html#environment-settings-object>environment settings object</a>'s
   <a href=webappapis.html#concept-settings-object-cross-origin-isolated-capability id=creating-browsing-contexts:concept-settings-object-cross-origin-isolated-capability>cross-origin isolated
   capability</a>.<li>
    <p>Let <var>document</var> be a new <code id=creating-browsing-contexts:document-2><a href=dom.html#document>Document</a></code>, with:</p>

    <dl class=props><dt><a href=https://dom.spec.whatwg.org/#concept-document-type id=creating-browsing-contexts:concept-document-type data-x-internal=concept-document-type>type</a><dd>"<code>html</code>"<dt><a href=https://dom.spec.whatwg.org/#concept-document-content-type id=creating-browsing-contexts:concept-document-content-type data-x-internal=concept-document-content-type>content type</a><dd>"<code id=creating-browsing-contexts:text/html><a href=iana.html#text/html>text/html</a></code>"<dt><a href=https://dom.spec.whatwg.org/#concept-document-mode id=creating-browsing-contexts:concept-document-mode data-x-internal=concept-document-mode>mode</a><dd>"<code>quirks</code>"<dt><a href=https://dom.spec.whatwg.org/#concept-document-origin id=creating-browsing-contexts:concept-document-origin-2 data-x-internal=concept-document-origin>origin</a><dd><var>origin</var><dt><a href=#concept-document-bc id=creating-browsing-contexts:concept-document-bc-2>browsing context</a><dd><var>browsingContext</var>

     <dt><a href=dom.html#concept-document-permissions-policy id=creating-browsing-contexts:concept-document-permissions-policy>permissions policy</a><dd><var>permissionsPolicy</var><dt><a id=creating-browsing-contexts:active-sandboxing-flag-set href=browsers.html#active-sandboxing-flag-set>active sandboxing flag set</a><dd><var>sandboxFlags</var><dt><a id=creating-browsing-contexts:load-timing-info href=dom.html#load-timing-info>load timing info</a><dd><var>loadTimingInfo</var><dt><a id=creating-browsing-contexts:is-initial-about:blank href=dom.html#is-initial-about:blank>is initial <code>about:blank</code></a><dd>true<dt><a href=dom.html#concept-document-about-base-url id=creating-browsing-contexts:concept-document-about-base-url>about base URL</a><dd><var>creatorBaseURL</var><dt><a href=https://dom.spec.whatwg.org/#concept-document-allow-declarative-shadow-roots id=creating-browsing-contexts:concept-document-allow-declarative-shadow-roots data-x-internal=concept-document-allow-declarative-shadow-roots>allow declarative shadow
     roots</a><dd>true<dt><a href=https://dom.spec.whatwg.org/#document-custom-element-registry id=creating-browsing-contexts:document-custom-element-registry data-x-internal=document-custom-element-registry>custom element registry</a><dd>a new <code id=creating-browsing-contexts:customelementregistry><a href=custom-elements.html#customelementregistry>CustomElementRegistry</a></code> object</dl>
   <li>
    <p>If <var>creator</var> is non-null, then:</p>

    <ol><li><p>Set <var>document</var>'s <a href="dom.html#the-document's-referrer" id="creating-browsing-contexts:the-document's-referrer">referrer</a> to the
     <a href=https://url.spec.whatwg.org/#concept-url-serializer id=creating-browsing-contexts:concept-url-serializer data-x-internal=concept-url-serializer>serialization</a> of <var>creator</var>'s <a href=https://dom.spec.whatwg.org/#concept-document-url id="creating-browsing-contexts:the-document's-address" data-x-internal="the-document's-address">URL</a>.<li><p>Set <var>document</var>'s <a href=dom.html#concept-document-policy-container id=creating-browsing-contexts:concept-document-policy-container>policy
     container</a> to a <a href=browsers.html#clone-a-policy-container id=creating-browsing-contexts:clone-a-policy-container>clone</a> of
     <var>creator</var>'s <a href=dom.html#concept-document-policy-container id=creating-browsing-contexts:concept-document-policy-container-2>policy
     container</a>.<li><p>If <var>creator</var>'s <a href=https://dom.spec.whatwg.org/#concept-document-origin id=creating-browsing-contexts:concept-document-origin-3 data-x-internal=concept-document-origin>origin</a> is
     <a id=creating-browsing-contexts:same-origin href=browsers.html#same-origin>same origin</a> with <var>creator</var>'s <a id=creating-browsing-contexts:relevant-settings-object-3 href=webappapis.html#relevant-settings-object>relevant settings object</a>'s
     <a id=creating-browsing-contexts:concept-environment-top-level-origin-2 href=webappapis.html#concept-environment-top-level-origin>top-level origin</a>, then set <var>document</var>'s <a href=dom.html#concept-document-coop id=creating-browsing-contexts:concept-document-coop>opener policy</a> to <var>creator</var>'s <a href=#concept-document-bc id=creating-browsing-contexts:concept-document-bc-3>browsing context</a>'s <a href=#bc-tlbc id=creating-browsing-contexts:bc-tlbc-2>top-level
     browsing context</a>'s <a href=#active-document id=creating-browsing-contexts:active-document>active document</a>'s <a href=dom.html#concept-document-coop id=creating-browsing-contexts:concept-document-coop-2>opener policy</a>.</ol>
   <li><p><a id=creating-browsing-contexts:assert href=https://infra.spec.whatwg.org/#assert data-x-internal=assert>Assert</a>: <var>document</var>'s <a href=https://dom.spec.whatwg.org/#concept-document-url id="creating-browsing-contexts:the-document's-address-2" data-x-internal="the-document's-address">URL</a>
   and <var>document</var>'s <a id=creating-browsing-contexts:relevant-settings-object-4 href=webappapis.html#relevant-settings-object>relevant settings object</a>'s <a href=webappapis.html#concept-environment-creation-url id=creating-browsing-contexts:concept-environment-creation-url>creation URL</a> are
   <code id=creating-browsing-contexts:about:blank-4><a href=infrastructure.html#about:blank>about:blank</a></code>.<li><p>Mark <var>document</var> as <a id=creating-browsing-contexts:ready-for-post-load-tasks href=parsing.html#ready-for-post-load-tasks>ready for post-load tasks</a>.<li><p><a id=creating-browsing-contexts:populate-with-html/head/body href=document-lifecycle.html#populate-with-html/head/body>Populate with <code>html</code>/<code>head</code>/<code>body</code></a> given
   <var>document</var>.<li><p><a id=creating-browsing-contexts:make-active href=browsing-the-web.html#make-active>Make active</a> <var>document</var>.<li><p><a id=creating-browsing-contexts:completely-finish-loading href=document-lifecycle.html#completely-finish-loading>Completely finish loading</a> <var>document</var>.<li><p>Return <var>browsingContext</var> and <var>document</var>.</ol>

  <p>To <dfn id=creating-a-new-top-level-browsing-context>create a new top-level browsing context and document</dfn>:</p>

  <ol><li><p>Let <var>group</var> and <var>document</var> be the result of <a href=#creating-a-new-browsing-context-group-and-document id=creating-browsing-contexts:creating-a-new-browsing-context-group-and-document>creating a new
   browsing context group and document</a>.<li><p>Return <var>group</var>'s <a href=#browsing-context-set id=creating-browsing-contexts:browsing-context-set>browsing context set</a>[0] and
   <var>document</var>.</ol>

  <p>To <dfn id=creating-a-new-auxiliary-browsing-context>create a new auxiliary browsing context and document</dfn>, given
  a <a href=#browsing-context id=creating-browsing-contexts:browsing-context-2>browsing context</a> <var>opener</var>:</p>

  <ol><li><p>Let <var>openerTopLevelBrowsingContext</var> be <var>opener</var>'s <a href=#bc-traversable id=creating-browsing-contexts:bc-traversable>top-level traversable</a>'s <a href=#nav-bc id=creating-browsing-contexts:nav-bc>active browsing
   context</a>.<li><p>Let <var>group</var> be <var>openerTopLevelBrowsingContext</var>'s <a href=#tlbc-group id=creating-browsing-contexts:tlbc-group>group</a>.<li><p><a id=creating-browsing-contexts:assert-2 href=https://infra.spec.whatwg.org/#assert data-x-internal=assert>Assert</a>: <var>group</var> is non-null, as <a href=browsing-the-web.html#navigate id=creating-browsing-contexts:navigate>navigating</a> invokes this directly.<li><p>Let <var>browsingContext</var> and <var>document</var> be the result of <a href=#creating-a-new-browsing-context id=creating-browsing-contexts:creating-a-new-browsing-context>creating a
   new browsing context and document</a> with <var>opener</var>'s <a href=#nav-document id=creating-browsing-contexts:nav-document>active document</a>, null, and <var>group</var>.<li><p>Set <var>browsingContext</var>'s <a href=#is-auxiliary id=creating-browsing-contexts:is-auxiliary>is auxiliary</a> to true.<li><p><a href=#bcg-append id=creating-browsing-contexts:bcg-append>Append</a> <var>browsingContext</var> to
   <var>group</var>.<li><p>Set <var>browsingContext</var>'s <a href=#opener-browsing-context id=creating-browsing-contexts:opener-browsing-context>opener browsing context</a> to
   <var>opener</var>.<li><p>Set <var>browsingContext</var>'s <a href=#virtual-browsing-context-group-id id=creating-browsing-contexts:virtual-browsing-context-group-id-3>virtual
   browsing context group ID</a> to <var>openerTopLevelBrowsingContext</var>'s <a href=#virtual-browsing-context-group-id id=creating-browsing-contexts:virtual-browsing-context-group-id-4>virtual browsing context group ID</a>.<li><p>Set <var>browsingContext</var>'s <a href=#opener-origin-at-creation id=creating-browsing-contexts:opener-origin-at-creation>opener origin
   at creation</a> to <var>opener</var>'s <a href=#nav-document id=creating-browsing-contexts:nav-document-2>active document</a>'s
   <a href=https://dom.spec.whatwg.org/#concept-document-origin id=creating-browsing-contexts:concept-document-origin-4 data-x-internal=concept-document-origin>origin</a>.<li><p>Return <var>browsingContext</var> and <var>document</var>.</ol>

  <p>To <dfn id=determining-the-origin>determine the origin</dfn>, given a <a id=creating-browsing-contexts:url href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a>
  <var>url</var>, a <a id=creating-browsing-contexts:sandboxing-flag-set href=browsers.html#sandboxing-flag-set>sandboxing flag set</a> <var>sandboxFlags</var>, and an
  <a id=creating-browsing-contexts:concept-origin href=browsers.html#concept-origin>origin</a>-or-null <var>sourceOrigin</var>:</p>

  <ol><li id=sandboxOrigin><p>If <var>sandboxFlags</var> has its <a id=creating-browsing-contexts:sandboxed-origin-browsing-context-flag href=browsers.html#sandboxed-origin-browsing-context-flag>sandboxed origin browsing
   context flag</a> set, then return a new <a href=browsers.html#concept-origin-opaque id=creating-browsing-contexts:concept-origin-opaque>opaque
   origin</a>.<li><p>If <var>url</var> is null, then return a new <a href=browsers.html#concept-origin-opaque id=creating-browsing-contexts:concept-origin-opaque-2>opaque
   origin</a>.<li>
    <p>If <var>url</var> is <code id=creating-browsing-contexts:about:srcdoc><a href=urls-and-fetching.html#about:srcdoc>about:srcdoc</a></code>, then:</p>

    <ol><li><p><a id=creating-browsing-contexts:assert-3 href=https://infra.spec.whatwg.org/#assert data-x-internal=assert>Assert</a>: <var>sourceOrigin</var> is non-null.<li><p>Return <var>sourceOrigin</var>.</ol>
   <li><p>If <var>url</var> <a id=creating-browsing-contexts:matches-about:blank href=urls-and-fetching.html#matches-about:blank>matches <code>about:blank</code></a> and
   <var>sourceOrigin</var> is non-null, then return <var>sourceOrigin</var>.<li><p>Return <var>url</var>'s <a href=https://url.spec.whatwg.org/#concept-url-origin id=creating-browsing-contexts:concept-url-origin data-x-internal=concept-url-origin>origin</a>.</ol>

  <p class=note>The cases that return <var>sourceOrigin</var> result in two
  <code id=creating-browsing-contexts:document-3><a href=dom.html#document>Document</a></code>s that end up with the same underlying <a href=https://dom.spec.whatwg.org/#concept-document-origin id=creating-browsing-contexts:concept-document-origin-5 data-x-internal=concept-document-origin>origin</a>, meaning that <code id=creating-browsing-contexts:dom-document-domain><a href=browsers.html#dom-document-domain>document.domain</a></code> affects both.</p>


  <h5 id=nested-browsing-contexts><span class=secno>7.3.2.2</span> Related browsing contexts<a href=#nested-browsing-contexts class=self-link></a></h5>

  <p>A <a href=#browsing-context id=nested-browsing-contexts:browsing-context>browsing context</a> <var>potentialDescendant</var> is said to be an <dfn id=ancestor-browsing-context>ancestor</dfn> of a browsing context
  <var>potentialAncestor</var> if the following algorithm returns true:</p>

  <ol><li><p>Let <var>potentialDescendantDocument</var> be <var>potentialDescendant</var>'s
   <a href=#active-document id=nested-browsing-contexts:active-document>active document</a>.<li><p>If <var>potentialDescendantDocument</var> is not <a href=#fully-active id=nested-browsing-contexts:fully-active>fully active</a>, then return
   false.<li><p>Let <var>ancestorBCs</var> be the list obtained by taking the <a href=#concept-document-bc id=nested-browsing-contexts:concept-document-bc>browsing context</a> of the <a href=#nav-document id=nested-browsing-contexts:nav-document>active
   document</a> of each member of <var>potentialDescendantDocument</var>'s <a href=#ancestor-navigables id=nested-browsing-contexts:ancestor-navigables>ancestor
   navigables</a>.<li><p>If <var>ancestorBCs</var> <a href=https://infra.spec.whatwg.org/#list-contain id=nested-browsing-contexts:list-contains data-x-internal=list-contains>contains</a>
   <var>potentialAncestor</var>, then return true.<li><p>Return false.</ol>

  <p>A <dfn id=top-level-browsing-context data-export="">top-level browsing context</dfn> is a <a href=#browsing-context id=nested-browsing-contexts:browsing-context-2>browsing context</a> whose
  <a href=#active-document id=nested-browsing-contexts:active-document-2>active document</a>'s <a href=#node-navigable id=nested-browsing-contexts:node-navigable>node navigable</a> is a <a href=#traversable-navigable id=nested-browsing-contexts:traversable-navigable>traversable
  navigable</a>.</p>

  <p class=note>It is <em>not</em> required to be a <a href=#top-level-traversable id=nested-browsing-contexts:top-level-traversable>top-level traversable</a>.</p>

  <p>The <dfn id=bc-tlbc>top-level browsing context</dfn> of a <a href=#browsing-context id=nested-browsing-contexts:browsing-context-3>browsing context</a>
  <var>start</var> is the result of the following algorithm:</p>

  <ol><li><p>If <var>start</var>'s <a href=#active-document id=nested-browsing-contexts:active-document-3>active document</a> is not <a href=#fully-active id=nested-browsing-contexts:fully-active-2>fully active</a>, then
   return null.<li><p>Let <var>navigable</var> be <var>start</var>'s <a href=#active-document id=nested-browsing-contexts:active-document-4>active document</a>'s <a href=#node-navigable id=nested-browsing-contexts:node-navigable-2>node
   navigable</a>.<li><p>While <var>navigable</var>'s <a href=#nav-parent id=nested-browsing-contexts:nav-parent>parent</a> is not null, set
   <var>navigable</var> to <var>navigable</var>'s <a href=#nav-parent id=nested-browsing-contexts:nav-parent-2>parent</a>.<li><p>Return <var>navigable</var>'s <a href=#nav-bc id=nested-browsing-contexts:nav-bc>active browsing
   context</a>.</ol>

  <div id=warning-avoid-related-bc-terms class=warning>
   <p>The terms <a href=#ancestor-browsing-context id=nested-browsing-contexts:ancestor-browsing-context>ancestor browsing context</a> and <a href=#top-level-browsing-context id=nested-browsing-contexts:top-level-browsing-context>top-level browsing context</a>
   are rarely useful, since <a href=#browsing-context id=nested-browsing-contexts:browsing-context-4>browsing contexts</a> in general are
   <a href=#warning-avoid-using-bcs>usually the inappropriate specification concept to use</a>.
   Note in particular that when a <a href=#browsing-context id=nested-browsing-contexts:browsing-context-5>browsing context</a>'s <a href=#active-document id=nested-browsing-contexts:active-document-5>active document</a> is
   not <a href=#fully-active id=nested-browsing-contexts:fully-active-3>fully active</a>, it never counts as an ancestor or top-level browsing context, and
   as such these concepts are not useful when <a href=browsing-the-web.html#note-bfcache>bfcache</a> is in play.</p>

   <p>Instead, use concepts such as the <a href=#ancestor-navigables id=nested-browsing-contexts:ancestor-navigables-2>ancestor navigables</a> collection, the <a href=#nav-parent id=nested-browsing-contexts:nav-parent-3>parent navigable</a>, or a navigable's <a href=#nav-traversable id=nested-browsing-contexts:nav-traversable>top-level traversable</a>.</p>
  </div>

  <hr>

  <p id=security-1><span id=security-nav></span>A <a href=#browsing-context id=nested-browsing-contexts:browsing-context-6>browsing context</a> <var>A</var> is
  <dfn id=familiar-with>familiar with</dfn> a second <a href=#browsing-context id=nested-browsing-contexts:browsing-context-7>browsing context</a> <var>B</var> if the following
  algorithm returns true:</p>

  <ol><li><p>If <var>A</var>'s <a href=#active-document id=nested-browsing-contexts:active-document-6>active document</a>'s <a href=https://dom.spec.whatwg.org/#concept-document-origin id=nested-browsing-contexts:concept-document-origin data-x-internal=concept-document-origin>origin</a> is <a id=nested-browsing-contexts:same-origin href=browsers.html#same-origin>same origin</a> with <var>B</var>'s
   <a href=#active-document id=nested-browsing-contexts:active-document-7>active document</a>'s <a href=https://dom.spec.whatwg.org/#concept-document-origin id=nested-browsing-contexts:concept-document-origin-2 data-x-internal=concept-document-origin>origin</a>, then return
   true.<li><p>If <var>A</var>'s <a href=#bc-tlbc id=nested-browsing-contexts:bc-tlbc>top-level browsing context</a> is
   <var>B</var>, then return true.<li><p>If <var>B</var> is an <a href=#auxiliary-browsing-context id=nested-browsing-contexts:auxiliary-browsing-context>auxiliary browsing context</a> and <var>A</var> is
   <a href=#familiar-with id=nested-browsing-contexts:familiar-with>familiar with</a> <var>B</var>'s <a href=#opener-browsing-context id=nested-browsing-contexts:opener-browsing-context>opener browsing context</a>, then return
   true.<li>
    <p>If there exists an <a href=#ancestor-browsing-context id=nested-browsing-contexts:ancestor-browsing-context-2>ancestor browsing context</a> of <var>B</var> whose <a href=#active-document id=nested-browsing-contexts:active-document-8>active
    document</a> has the <a href=browsers.html#same-origin id=nested-browsing-contexts:same-origin-2>same</a> <a href=https://dom.spec.whatwg.org/#concept-document-origin id=nested-browsing-contexts:concept-document-origin-3 data-x-internal=concept-document-origin>origin</a> as the <a href=#active-document id=nested-browsing-contexts:active-document-9>active document</a> of
    <var>A</var>, then return true.</p>

    <p class=note>This includes the case where <var>A</var> is an <a href=#ancestor-browsing-context id=nested-browsing-contexts:ancestor-browsing-context-3>ancestor browsing
    context</a> of <var>B</var>.</p>
   <li><p>Return false.</ol>

  <h5 id=groupings-of-browsing-contexts><span class=secno>7.3.2.3</span> Groupings of browsing contexts<a href=#groupings-of-browsing-contexts class=self-link></a></h5>

  <p>A <a href=#top-level-browsing-context id=groupings-of-browsing-contexts:top-level-browsing-context>top-level browsing context</a> has an associated <dfn id=tlbc-group>group</dfn> (null or a <a href=#browsing-context-group id=groupings-of-browsing-contexts:browsing-context-group>browsing context group</a>). It is initially null.</p>

  <p>A user agent holds a <dfn id=browsing-context-group-set>browsing context group set</dfn> (a <a id=groupings-of-browsing-contexts:set href=https://infra.spec.whatwg.org/#ordered-set data-x-internal=set>set</a> of <a href=#browsing-context-group id=groupings-of-browsing-contexts:browsing-context-group-2>browsing context groups</a>).</p>

  <p>A <dfn id=browsing-context-group>browsing context group</dfn> holds a <dfn id=browsing-context-set>browsing context set</dfn> (a <a id=groupings-of-browsing-contexts:set-2 href=https://infra.spec.whatwg.org/#ordered-set data-x-internal=set>set</a>
  of <a href=#top-level-browsing-context id=groupings-of-browsing-contexts:top-level-browsing-context-2>top-level browsing contexts</a>).</p>

  <p class=note>A <a href=#top-level-browsing-context id=groupings-of-browsing-contexts:top-level-browsing-context-3>top-level browsing context</a> is added to the <a href=#browsing-context-group id=groupings-of-browsing-contexts:browsing-context-group-3>group</a> when the group is <a href=#creating-a-new-browsing-context-group-and-document id=groupings-of-browsing-contexts:creating-a-new-browsing-context-group-and-document>created</a>. All subsequent <a href=#top-level-browsing-context id=groupings-of-browsing-contexts:top-level-browsing-context-4>top-level
  browsing contexts</a> added to the <a href=#browsing-context-group id=groupings-of-browsing-contexts:browsing-context-group-4>group</a> will be
  <a href=#auxiliary-browsing-context id=groupings-of-browsing-contexts:auxiliary-browsing-context>auxiliary browsing contexts</a>.</p>

  <p>A <a href=#browsing-context-group id=groupings-of-browsing-contexts:browsing-context-group-5>browsing context group</a> has an associated <dfn id=agent-cluster-map>agent cluster map</dfn> (a weak
  <a href=https://infra.spec.whatwg.org/#ordered-map id=groupings-of-browsing-contexts:ordered-map data-x-internal=ordered-map>map</a> of <a href=webappapis.html#agent-cluster-key id=groupings-of-browsing-contexts:agent-cluster-key>agent cluster
  keys</a> to <a href=https://tc39.es/ecma262/#sec-agent-clusters id=groupings-of-browsing-contexts:agent-cluster data-x-internal=agent-cluster>agent clusters</a>). User agents are responsible
  for collecting agent clusters when it is deemed that nothing can access them anymore.</p>

  <p>A <a href=#browsing-context-group id=groupings-of-browsing-contexts:browsing-context-group-6>browsing context group</a> has an associated <dfn id=historical-agent-cluster-key-map>historical agent cluster key
  map</dfn>, which is a <a href=https://infra.spec.whatwg.org/#ordered-map id=groupings-of-browsing-contexts:ordered-map-2 data-x-internal=ordered-map>map</a> of <a href=browsers.html#concept-origin id=groupings-of-browsing-contexts:concept-origin>origins</a> to <a href=webappapis.html#agent-cluster-key id=groupings-of-browsing-contexts:agent-cluster-key-2>agent cluster keys</a>. This
  map is used to ensure the consistency of the <a href=browsers.html#origin-keyed-agent-clusters>origin-keyed
  agent clusters</a> feature by recording what agent cluster keys were previously used for a given
  origin.</p>

  <p class=note>The <a href=#historical-agent-cluster-key-map id=groupings-of-browsing-contexts:historical-agent-cluster-key-map>historical agent cluster key map</a> only ever gains entries over the
  lifetime of the browsing context group.</p>

  <p>A <a href=#browsing-context-group id=groupings-of-browsing-contexts:browsing-context-group-7>browsing context group</a> has a <dfn id=bcg-cross-origin-isolation>cross-origin isolation mode</dfn>, which is a
  <a href=#cross-origin-isolation-mode id=groupings-of-browsing-contexts:cross-origin-isolation-mode>cross-origin isolation mode</a>. It is initially "<code id=groupings-of-browsing-contexts:cross-origin-isolation-none><a href=#cross-origin-isolation-none>none</a></code>".</p>

  <p>A <dfn id=cross-origin-isolation-mode>cross-origin isolation mode</dfn> is one of three possible values: "<dfn id=cross-origin-isolation-none><code>none</code></dfn>", "<dfn id=cross-origin-isolation-logical><code>logical</code></dfn>", or "<dfn id=cross-origin-isolation-concrete><code>concrete</code></dfn>".</p>

  <div class=note>
   <p>"<code id=groupings-of-browsing-contexts:cross-origin-isolation-logical><a href=#cross-origin-isolation-logical>logical</a></code>" and "<code id=groupings-of-browsing-contexts:cross-origin-isolation-concrete><a href=#cross-origin-isolation-concrete>concrete</a></code>" are similar. They are both used for
   <a href=#browsing-context-group id=groupings-of-browsing-contexts:browsing-context-group-8>browsing context groups</a> where:</p>

   <ul><li><p>every top-level <code id=groupings-of-browsing-contexts:document><a href=dom.html#document>Document</a></code> has `<code><a id=groupings-of-browsing-contexts:cross-origin-opener-policy-2 href=browsers.html#cross-origin-opener-policy-2>Cross-Origin-Opener-Policy</a>: <a href=browsers.html#coop-same-origin id=groupings-of-browsing-contexts:coop-same-origin>same-origin</a></code>`, and<li><p>every <code id=groupings-of-browsing-contexts:document-2><a href=dom.html#document>Document</a></code> has a `<code id=groupings-of-browsing-contexts:cross-origin-embedder-policy><a href=browsers.html#cross-origin-embedder-policy>Cross-Origin-Embedder-Policy</a></code>` header
    whose value is <a id=groupings-of-browsing-contexts:compatible-with-cross-origin-isolation href=browsers.html#compatible-with-cross-origin-isolation>compatible with cross-origin isolation</a>.</ul>

   <p>On some platforms, it is difficult to provide the security properties required to grant safe
   access to the APIs gated by the <a href=webappapis.html#concept-settings-object-cross-origin-isolated-capability id=groupings-of-browsing-contexts:concept-settings-object-cross-origin-isolated-capability>cross-origin isolated
   capability</a>. As a result, only "<code id=groupings-of-browsing-contexts:cross-origin-isolation-concrete-2><a href=#cross-origin-isolation-concrete>concrete</a></code>" can grant access that capability.
   "<code id=groupings-of-browsing-contexts:cross-origin-isolation-logical-2><a href=#cross-origin-isolation-logical>logical</a></code>" is used on platform not supporting
   this capability, where various restrictions imposed by cross-origin isolation will still apply,
   but the capability is not granted.</p>
  </div>

  <p id=creating-a-new-browsing-context-group>To <dfn id=creating-a-new-browsing-context-group-and-document>create a new browsing context group and document</dfn>:</p>

  <ol><li><p>Let <var>group</var> be a new <a href=#browsing-context-group id=groupings-of-browsing-contexts:browsing-context-group-9>browsing context group</a>.<li><p><a href=https://infra.spec.whatwg.org/#set-append id=groupings-of-browsing-contexts:set-append data-x-internal=set-append>Append</a> <var>group</var> to the user agent's
   <a href=#browsing-context-group-set id=groupings-of-browsing-contexts:browsing-context-group-set>browsing context group set</a>.<li><p>Let <var>browsingContext</var> and <var>document</var> be the result of <a href=#creating-a-new-browsing-context id=groupings-of-browsing-contexts:creating-a-new-browsing-context>creating a
   new browsing context and document</a> with null, null, and <var>group</var>.<li><p><a href=#bcg-append id=groupings-of-browsing-contexts:bcg-append>Append</a> <var>browsingContext</var> to
   <var>group</var>.<li><p>Return <var>group</var> and <var>document</var>.</ol>

  <p>To <dfn id=bcg-append>append</dfn> a <a href=#top-level-browsing-context id=groupings-of-browsing-contexts:top-level-browsing-context-5>top-level browsing context</a>
  <var>browsingContext</var> to a <a href=#browsing-context-group id=groupings-of-browsing-contexts:browsing-context-group-10>browsing context group</a> <var>group</var>:</p>

  <ol><li><p><a href=https://infra.spec.whatwg.org/#set-append id=groupings-of-browsing-contexts:set-append-2 data-x-internal=set-append>Append</a> <var>browsingContext</var> to <var>group</var>'s
   <a href=#browsing-context-set id=groupings-of-browsing-contexts:browsing-context-set>browsing context set</a>.<li><p>Set <var>browsingContext</var>'s <a href=#tlbc-group id=groupings-of-browsing-contexts:tlbc-group>group</a> to
   <var>group</var>.</ol>

  <p>To <dfn id=bcg-remove>remove</dfn> a <a href=#top-level-browsing-context id=groupings-of-browsing-contexts:top-level-browsing-context-6>top-level browsing context</a>
  <var>browsingContext</var>:</p>

  <ol><li><p><a id=groupings-of-browsing-contexts:assert href=https://infra.spec.whatwg.org/#assert data-x-internal=assert>Assert</a>: <var>browsingContext</var>'s <a href=#tlbc-group id=groupings-of-browsing-contexts:tlbc-group-2>group</a>
   is non-null.<li><p>Let <var>group</var> be <var>browsingContext</var>'s <a href=#tlbc-group id=groupings-of-browsing-contexts:tlbc-group-3>group</a>.<li><p>Set <var>browsingContext</var>'s <a href=#tlbc-group id=groupings-of-browsing-contexts:tlbc-group-4>group</a> to null.<li><p><a href=https://infra.spec.whatwg.org/#list-remove id=groupings-of-browsing-contexts:list-remove data-x-internal=list-remove>Remove</a> <var>browsingContext</var> from
   <var>group</var>'s <a href=#browsing-context-set id=groupings-of-browsing-contexts:browsing-context-set-2>browsing context set</a>.<li><p>If <var>group</var>'s <a href=#browsing-context-set id=groupings-of-browsing-contexts:browsing-context-set-3>browsing context set</a> <a href=https://infra.spec.whatwg.org/#list-is-empty id=groupings-of-browsing-contexts:list-is-empty data-x-internal=list-is-empty>is
   empty</a>, then <a href=https://infra.spec.whatwg.org/#list-remove id=groupings-of-browsing-contexts:list-remove-2 data-x-internal=list-remove>remove</a> <var>group</var> from the user
   agent's <a href=#browsing-context-group-set id=groupings-of-browsing-contexts:browsing-context-group-set-2>browsing context group set</a>.</ol>

  <p class=note><a href=#bcg-append id=groupings-of-browsing-contexts:bcg-append-2>Append</a> and <a href=#bcg-remove id=groupings-of-browsing-contexts:bcg-remove>remove</a> are primitive operations that help define the lifetime of a <a href=#browsing-context-group id=groupings-of-browsing-contexts:browsing-context-group-11>browsing
  context group</a>. They are called by higher-level creation and destruction operations for
  <code id=groupings-of-browsing-contexts:document-3><a href=dom.html#document>Document</a></code>s and <a href=#browsing-context id=groupings-of-browsing-contexts:browsing-context>browsing contexts</a>.</p>

  <p id=a-browsing-context-is-discarded>When there are no <code id=groupings-of-browsing-contexts:document-4><a href=dom.html#document>Document</a></code> objects whose
  <a href=#concept-document-bc id=groupings-of-browsing-contexts:concept-document-bc>browsing context</a> equals a given <a href=#browsing-context id=groupings-of-browsing-contexts:browsing-context-2>browsing
  context</a> (i.e., all such <code id=groupings-of-browsing-contexts:document-5><a href=dom.html#document>Document</a></code>s have been <a href=document-lifecycle.html#destroy-a-document id=groupings-of-browsing-contexts:destroy-a-document>destroyed</a>), and that <a href=#browsing-context id=groupings-of-browsing-contexts:browsing-context-3>browsing context</a>'s <code id=groupings-of-browsing-contexts:windowproxy><a href=nav-history-apis.html#windowproxy>WindowProxy</a></code> is
  eligible for garbage collection, then the <a href=#browsing-context id=groupings-of-browsing-contexts:browsing-context-4>browsing context</a> will never be accessed
  again. If it is a <a href=#top-level-browsing-context id=groupings-of-browsing-contexts:top-level-browsing-context-7>top-level browsing context</a>, then at this point the user agent must
  <a href=#bcg-remove id=groupings-of-browsing-contexts:bcg-remove-2>remove</a> it.</p>


  <h4 id=fully-active-documents><span class=secno>7.3.3</span> Fully active documents<a href=#fully-active-documents class=self-link></a></h4>

  <p>A <code id=fully-active-documents:document><a href=dom.html#document>Document</a></code> <var>d</var> is said to be <dfn data-dfn-for=Document id=fully-active data-export="">fully
  active</dfn> when <var>d</var> is the <a href=#nav-document id=fully-active-documents:nav-document>active document</a> of a
  <a href=#navigable id=fully-active-documents:navigable>navigable</a> <var>navigable</var>, and either <var>navigable</var> is a <a href=#top-level-traversable id=fully-active-documents:top-level-traversable>top-level
  traversable</a> or <var>navigable</var>'s <a href=#nav-container-document id=fully-active-documents:nav-container-document>container
  document</a> is <a href=#fully-active id=fully-active-documents:fully-active>fully active</a>.</p>

  <p>Because they are associated with an element, <a href=#child-navigable id=fully-active-documents:child-navigable>child
  navigables</a> are always tied to a specific <code id=fully-active-documents:document-2><a href=dom.html#document>Document</a></code>, their <a href=#nav-container-document id=fully-active-documents:nav-container-document-2>container document</a>, in their <a href=#nav-parent id=fully-active-documents:nav-parent>parent navigable</a>. User agents must not allow the user to interact with
  <a href=#child-navigable id=fully-active-documents:child-navigable-2>child navigables</a> whose <a href=#nav-container-document id=fully-active-documents:nav-container-document-3>container documents</a> are not themselves <a href=#fully-active id=fully-active-documents:fully-active-2>fully
  active</a>.</p>

  <div class=example>
   <p>The following example illustrates how a <code id=fully-active-documents:document-3><a href=dom.html#document>Document</a></code> can be the <a href=#nav-document id=fully-active-documents:nav-document-2>active document</a> of its <a href=#node-navigable id=fully-active-documents:node-navigable>node navigable</a>, while not being
   <a href=#fully-active id=fully-active-documents:fully-active-3>fully active</a>. Here <code>a.html</code> is loaded into a browser window,
   <code>b-1.html</code> starts out loaded into an <code id=fully-active-documents:the-iframe-element><a href=iframe-embed-object.html#the-iframe-element>iframe</a></code> as shown, and
   <code>b-2.html</code> and <code>c.html</code> are omitted (they can simply
   be an empty document).</p>

   <pre><code class='html'><c- c>&lt;!-- a.html --&gt;</c->
<c- cp>&lt;!DOCTYPE html&gt;</c->
<c- p>&lt;</c-><c- f>html</c-> <c- e>lang</c-><c- o>=</c-><c- s>&quot;en&quot;</c-><c- p>&gt;</c->
<c- p>&lt;</c-><c- f>title</c-><c- p>&gt;</c->Navigable A<c- p>&lt;/</c-><c- f>title</c-><c- p>&gt;</c->

<c- p>&lt;</c-><c- f>iframe</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;b-1.html&quot;</c-><c- p>&gt;&lt;/</c-><c- f>iframe</c-><c- p>&gt;</c->
<c- p>&lt;</c-><c- f>button</c-> <c- e>onclick</c-><c- o>=</c-><c- s>&quot;frames[0].location.href = &apos;b-2.html&apos;&quot;</c-><c- p>&gt;</c->Click me<c- p>&lt;/</c-><c- f>button</c-><c- p>&gt;</c->

<c- c>&lt;!-- b-1.html --&gt;</c->
<c- cp>&lt;!DOCTYPE html&gt;</c->
<c- p>&lt;</c-><c- f>html</c-> <c- e>lang</c-><c- o>=</c-><c- s>&quot;en&quot;</c-><c- p>&gt;</c->
<c- p>&lt;</c-><c- f>title</c-><c- p>&gt;</c->Navigable B<c- p>&lt;/</c-><c- f>title</c-><c- p>&gt;</c->

<c- p>&lt;</c-><c- f>iframe</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;c.html&quot;</c-><c- p>&gt;&lt;/</c-><c- f>iframe</c-><c- p>&gt;</c-></code></pre>

   <p>At this point, the documents given by <code>a.html</code>, <code>b-1.html</code>, and <code>c.html</code> are all the <a href=#nav-document id=fully-active-documents:nav-document-3>active documents</a> of their respective <a href=#node-navigable id=fully-active-documents:node-navigable-2>node navigables</a>. They are also all <a href=#fully-active id=fully-active-documents:fully-active-4>fully active</a>.</p>

   <p>After clicking on the <code id=fully-active-documents:the-button-element><a href=form-elements.html#the-button-element>button</a></code>, and thus loading a new <code id=fully-active-documents:document-4><a href=dom.html#document>Document</a></code> from
   <code>b-2.html</code> into navigable B, we have the following results:</p>

   <ul><li><p>The <code>a.html</code> <code id=fully-active-documents:document-5><a href=dom.html#document>Document</a></code> remains both the <a href=#nav-document id=fully-active-documents:nav-document-4>active document</a> of navigable A, and <a href=#fully-active id=fully-active-documents:fully-active-5>fully
    active</a>.<li><p>The <code>b-1.html</code> <code id=fully-active-documents:document-6><a href=dom.html#document>Document</a></code> is now <em>not</em> the <a href=#nav-document id=fully-active-documents:nav-document-5>active document</a> of navigable B. As such it is also not <a href=#fully-active id=fully-active-documents:fully-active-6>fully
    active</a>.<li><p>The new <code>b-2.html</code> <code id=fully-active-documents:document-7><a href=dom.html#document>Document</a></code> is now the <a href=#nav-document id=fully-active-documents:nav-document-6>active document</a> of navigable B, and is also <a href=#fully-active id=fully-active-documents:fully-active-7>fully
    active</a>.<li><p>The <code>c.html</code> <code id=fully-active-documents:document-8><a href=dom.html#document>Document</a></code> is still the <a href=#nav-document id=fully-active-documents:nav-document-7>active document</a> of navigable C. However, since C's <a href=#nav-container-document id=fully-active-documents:nav-container-document-4>container document</a> is the <code>b-1.html</code> <code id=fully-active-documents:document-9><a href=dom.html#document>Document</a></code>, which is itself not <a href=#fully-active id=fully-active-documents:fully-active-8>fully active</a>,
    this means the <code>c.html</code> <code id=fully-active-documents:document-10><a href=dom.html#document>Document</a></code> is now not <a href=#fully-active id=fully-active-documents:fully-active-9>fully
    active</a>.</ul>
  </div>


  <nav><a href=nav-history-apis.html>← 7.2 APIs related to navigation and
  session history</a> — <a href=index.html>Table of Contents</a> — <a href=browsing-the-web.html>7.4 Navigation and session
  history →</a></nav>
